OpenTkEngine.Core.ModelMesh.BindVAO C# (CSharp) Method

BindVAO() public method

public BindVAO ( ) : void
return void
        public void BindVAO()
        {
            if (_vaoID == 0)
            {
                _vaoID = GL.GenVertexArray();
            }
            GL.BindVertexArray(_vaoID);
            if (!_vbosBound) BindVBO();
            if (_material != null)
                _material.Bind();
        }

Usage Example

Example #1
0
        public static void RenderModelMesh(ModelMesh mesh, Matrix4 matrix, int offset, int count, Color4 color)
        {
            SetColor(color);
            Texture.BindNone();
            Lighting.EnableLighting();
            if (_currentVao != mesh.GetVaoID())
            {
                mesh.BindVAO();
                _currentVao = mesh.GetVaoID();
            }
            int uModelLocation = _currentShader.GetUniformLocation("uModel");
            GL.UniformMatrix4(uModelLocation, true, ref matrix);

            if (_worldMatrixChanged)
            {
                int uWorldLocation = _currentShader.GetUniformLocation("uWorld");
                Matrix4 worldMatrix = _worldMatrixStack.Count > 0 ? (Matrix4)_worldMatrixStack.Peek() : _worldMatrix;
                GL.UniformMatrix4(uWorldLocation, true, ref worldMatrix);
                Lighting.ApplyLightMatrix(worldMatrix);
            }

            GL.DrawElements(PrimitiveType.Triangles, count, DrawElementsType.UnsignedInt, offset * sizeof(uint));
            Lighting.DisableLighting();
        }