/// <summary> /// Sets up a new vertex array object if needing to be updated. /// </summary> private void UpdateArray() { if (m_dirty && m_program != null && m_vertexBuffer != null) { // destroy the old vertex array if (m_vertexArrayGenerated) { GL.DeleteVertexArray(this); m_vertexArrayGenerated = false; } // create a new vertex array m_handle = GL.GenVertexArray(); m_vertexArrayGenerated = true; // bind the new array GL.BindVertexArray(this); // set the source vertex and index buffers m_vertexBuffer.Bind(); if (m_indexBuffer != null) { m_indexBuffer.Bind(); } // set the vertex attributes m_program.SetVertexAttributes(m_vertexBuffer.VertexAttributes); // unbind all the buffers GL.BindVertexArray(0); m_vertexBuffer.Unbind(); if (m_indexBuffer != null) { m_indexBuffer.Unbind(); } m_dirty = false; } }