public VertexBufferObject(bool isStatic, int numVertices, int vertexSize, VertexAttributes attrs) { this.hint = isStatic ? BufferUsageHint.StaticDraw : BufferUsageHint.DynamicDraw; this.attributes = attrs; vertices = new float[numVertices * vertexSize]; dirty = true; this.numVertices = numVertices; GL.GenBuffers(1, out bufferHandle); }
public static Mesh generateTextureQuad() { VertexAttributes attrs = new VertexAttributes(VertexAttribute.Position(), VertexAttribute.TexCoords(0)); Mesh mesh = new Mesh(true, 4, 5, attrs); mesh.setVerticies(ref quadTextureVerts); mesh.setIndicies(ref quadTextureIndencies); return(mesh); }
public static Mesh screenQuad(ref Camera camera, int textureUnit) { VertexAttributes attrs = new VertexAttributes(VertexAttribute.Position(), VertexAttribute.TexCoords(textureUnit)); Mesh mesh = new Mesh(true, 4, 5, attrs); Vector3 vec0 = Vector3.Zero; camera.unproject(ref vec0); Vector3 vec1 = new Vector3(Game.shared.width, Game.shared.height, 0); camera.unproject(ref vec1); mesh.setVertices(new float[] { vec0.X, vec0.Y, 0, 0, 1, vec1.X, vec0.Y, 0, 1, 1, vec1.X, vec1.Y, 0, 1, 0, vec0.X, vec1.Y, 0, 0, 0 }); mesh.setIndices(new uint[] { 0, 1, 2, 2, 3, 0 }); return(mesh); }
public Mesh(bool isStatic, int numVertices, int vertexSize, VertexAttributes attrs) { verticies = new VertexBufferObject(isStatic, numVertices, vertexSize, attrs); indicies = new IndexBufferObject(isStatic); Game.glResources.Add(this); }