public void Draw(Spritebatch spritebatch) { for (int i = 0; i < TextureQuads.Count; i++) { TextureQuads[i].Draw(spritebatch); } }
private void CreateTexture() { var bitmap = new Bitmap("Textures/Containers/container001-blue.png"); Spritebatch.GenerateTexture(bitmap, out this.blueTexture); var bitmap2 = new Bitmap("Textures/Containers/container001-green.png"); Spritebatch.GenerateTexture(bitmap2, out this.greenTexture); }
// Settings, load textures, sounds protected override void OnLoad(EventArgs e) { base.OnLoad(e); VSync = VSyncMode.On; GL.Viewport(0, 0, Width, Height); lastMousePos = new Vector2(); camera = new Camera(Width, Height); camera.Position = new Vector3(0, 10, 20); spritebatch = new Spritebatch(camera); grid = new Grid(Color.White); quadHandler = new QuadHandler(); sierpinskiCarpet = new SierpinskiCarpet(12); }
public void Draw(Spritebatch spritebatch) { spritebatch.Begin <ColorProgram>(); // Matrix transformation Matrix4 transformationMatrix = modelMatrix * spritebatch.Camera.GetViewProjectionMatrix(); GL.UniformMatrix4(spritebatch.ColorProgram.ModelViewUniform, false, ref transformationMatrix); // Attribute pointers GL.BindBuffer(BufferTarget.ArrayBuffer, verticesBuffer.MemoryLocation); GL.VertexAttribPointer(spritebatch.ColorProgram.PositionAttribute, 3, VertexAttribPointerType.Float, false, 0, 0); GL.BindBuffer(BufferTarget.ArrayBuffer, colorBuffer.MemoryLocation); GL.VertexAttribPointer(spritebatch.ColorProgram.ColorAttribute, 3, VertexAttribPointerType.Float, false, 0, 0); GL.DrawArrays(PrimitiveType.Lines, 0, verticesBuffer.Length); spritebatch.End(); }
public void Draw(Spritebatch spritebatch) { // Matrix transformation Matrix4 transformationMatrix = modelMatrix * spritebatch.Camera.GetViewProjectionMatrix(); GL.UniformMatrix4(spritebatch.TextureProgram.ModelViewUniform, false, ref transformationMatrix); // Use texture GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, this.Texture); GL.Uniform1(spritebatch.TextureProgram.TextureUniform, (int)TextureUnit.Texture0); // Attribute pointers GL.BindBuffer(BufferTarget.ArrayBuffer, VerticesBuffer.MemoryLocation); GL.VertexAttribPointer(spritebatch.TextureProgram.PositionAttribute, 3, VertexAttribPointerType.Float, false, 0, 0); GL.BindBuffer(BufferTarget.ArrayBuffer, TexturePointBuffer.MemoryLocation); GL.VertexAttribPointer(spritebatch.TextureProgram.TexturePointsAttribute, 2, VertexAttribPointerType.Float, false, 0, 0); GL.DrawArrays(PrimitiveType.Quads, 0, VerticesBuffer.Length); }