public VertexArrayObject(BufferObject <TVerexType> vbo, BufferObject <TIndexType> ibo) { _id = GL.GenVertexArray(); Bind(); vbo.Bind(); ibo.Bind(); }
public void End() { // dont allow for end to be called twice if (!_beginCalled) { throw new Exception("Cannot call end before calling begin"); } _beginCalled = false; // on end we have to bind all the data to the vbo _quadVbo.Bind(); int size = _quadCount * 4 * VertexSize * sizeof(float); GL.BufferSubData <float>(BufferTarget.ArrayBuffer, IntPtr.Zero, size, _vertices); // also bind every texture for (int i = 0; i < _textures.Count; i++) { _textures[i].Bind(TextureUnit.Texture0 + i + 1); } // and finally draw everything _quadVao.Bind(); _quadShader.Bind(); GL.DrawElements(BeginMode.Triangles, _quadCount * 6, DrawElementsType.UnsignedInt, 0); // also reset the quadCount _quadCount = 0; }