private void setupVertexArray(Shader shader) { bool initial = currentShader == null; if (initial) { vertexArrayId = GL.GenVertexArray(); } GL.BindVertexArray(vertexArrayId); // Vertex GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferId); if (!initial) { vertexDeclaration.DeactivateAttributes(currentShader); } vertexDeclaration.ActivateAttributes(shader); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); // Index if (initial && indexBufferId != -1) { GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBufferId); } GL.BindVertexArray(0); currentShader = shader; }
protected virtual void internalUnbind() { GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); vertexDeclaration.DeactivateAttributes(currentShader); currentShader = null; }