private void GraphicsBox_Render(object sender, GraphicsContextEventArgs e) { e.Graphics.Clear(); e.Graphics.ShaderProgram = this.currentShaderProgram; Vector2 size = new Vector2(this.currentPicture.Width, this.currentPicture.Height); Samurai.Rectangle viewport = e.Graphics.Viewport; this.transform.M11 = 2f / viewport.Width; this.transform.M22 = -2f / viewport.Height; this.currentShaderProgram.SetValue("vertSize", ref size); this.currentShaderProgram.SetValue("vertTransform", ref this.transform); this.currentShaderProgram.SetValue("picture", this.currentPicture); Vector2 pictureSize = new Vector2(this.currentPicture.Width, this.currentPicture.Height); this.currentShaderProgram.SetValue("pictureSize", ref pictureSize); this.currentShaderProgram.SetValue("time", (float)this.stopwatch.ElapsedMilliseconds); e.Graphics.Draw(PrimitiveType.Triangles, this.vertexBuffer); }
private void GraphicsBox_GraphicsContextCreated(object sender, GraphicsContextEventArgs e) { e.Graphics.ClearColor = Color4.CornflowerBlue; this.vertexBuffer = new StaticVertexBuffer<Vertex>(e.Graphics, new Vertex[] { new Vertex() { Position = Vector2.Zero, TexCoords = Vector2.Zero }, new Vertex() { Position = Vector2.UnitX, TexCoords = Vector2.UnitX }, new Vertex() { Position = Vector2.UnitY, TexCoords = Vector2.UnitY }, new Vertex() { Position = Vector2.UnitY, TexCoords = Vector2.UnitY }, new Vertex() { Position = Vector2.UnitX, TexCoords = Vector2.UnitX }, new Vertex() { Position = Vector2.One, TexCoords = Vector2.One }, }); this.currentShaderProgram = new ShaderProgram( e.Graphics, VertexShader.Compile(e.Graphics, vertexShaderCode), FragmentShader.Compile(e.Graphics, defaultFragmentShaderCode)); this.currentPicture = Texture2D.LoadFromFile(e.Graphics, "SamuraiLogo.png", new TextureParams()); this.stopwatch.Start(); }
protected virtual void OnRender(GraphicsContextEventArgs e) { if (this.Render != null) this.Render(this, e); }
protected virtual void OnGraphicsContextCreated(GraphicsContextEventArgs e) { this.oldWindowWidth = (int)this.ActualWidth; this.oldWindowHeight = (int)this.ActualHeight; if (this.GraphicsContextCreated != null) this.GraphicsContextCreated(this, e); }
private void Canvas_Render(object sender, GraphicsContextEventArgs e) { e.Graphics.Clear(); }
private void Canvas_ContextCreated(object sender, GraphicsContextEventArgs e) { }