private MapChunkData _initChunkBuffers(IMapGrid grid, IMapChunk chunk) { var vao = (uint)GL.GenVertexArray(); GL.BindVertexArray(vao); var vboSize = _verticesPerChunk(chunk) * Vertex2D.SizeOf; var eboSize = _indicesPerChunk(chunk) * sizeof(ushort); var vbo = new GLBuffer(this, BufferTarget.ArrayBuffer, BufferUsageHint.DynamicDraw, vboSize, $"Grid {grid.Index} chunk {chunk.Indices} VBO"); var ebo = new GLBuffer(this, BufferTarget.ElementArrayBuffer, BufferUsageHint.DynamicDraw, eboSize, $"Grid {grid.Index} chunk {chunk.Indices} EBO"); ObjectLabelMaybe(ObjectLabelIdentifier.VertexArray, vao, $"Grid {grid.Index} chunk {chunk.Indices} VAO"); // Vertex Coords GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, Vertex2D.SizeOf, 0); GL.EnableVertexAttribArray(0); // Texture Coords. GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, Vertex2D.SizeOf, 2 * sizeof(float)); GL.EnableVertexAttribArray(1); // Assign VBO and EBO to VAO. // OpenGL 3.x is such a good API. vbo.Use(); ebo.Use(); var datum = new MapChunkData(vao, vbo, ebo) { Dirty = true }; _mapChunkData[grid.Index].Add(chunk.Indices, datum); return(datum); }