Exemplo n.º 1
0
        public void Flush()
        {
            // Return if there's nothing to draw
            if (indexCount == 0)
            {
                return;
            }

            // Use the shader program
            Program.Use(shader => {
                // Bind the array buffer object
                GL.BindVertexArray(abo);

                // Upload vertices to the vertex buffer object
                vbo.UploadData(dataArray: Vertices);

                // Point the vertex buffer object to the right point
                vbo.PointTo(shader.Attrib("v_pos"), 2, 0);
                vbo.PointTo(shader.Attrib("v_tex"), 2, 3 * sizeof(float));
                vbo.PointTo(shader.Attrib("v_col"), 4, 5 * sizeof(float));

                // Bind the current texture to texture unit 0
                CurrentTexture.Bind(TextureUnit.Texture0);

                // Bind the index buffer object
                ibo.Bind();

                // Set the MVP uniform to the view projection matrix of the camera
                shader["MVP"] = CurrentCamera.ViewProjectionMatrix;

                // Draw the elements
                GL.DrawElements(BeginMode.Triangles, ibo.Buffer.Count, DrawElementsType.UnsignedInt, 0);

                // Unbind the array buffer object
                GL.BindVertexArray(0);

                Array.Clear(Vertices, 0, Vertices.Length);

                // Reset the vertex and index counts
                vertexCount = 0;
                indexCount  = 0;
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Bind the buffer.
 /// </summary>
 public void Bind()
 {
     // Bind the buffer
     GLBuffer <T> .Bind(this);
 }