I'd like to lay out some things I think I've learned, but am unsure about:
- VBOs are the way to go. They're created with
glGenBuffersandglBufferData. - For maximum flexibility, it's best to pass generic vertex attributes to shaders with
glVertexAttribPointer, rather thanglVertex,glNormal, etc.. glDrawElementscan be used with vertex buffers and an index buffer to efficiently render geometry with lots of shared vertices, such as a landscape mesh.
Assuming all of that is correct so far, here's my question. All of the tutorials I've read about modern OpenGL completely omit glEnableClientState. But the OpenGL man pages say that without glEnableClientState, glDrawElements will do nothing:
http://www.opengl.org/sdk/docs/man/xhtml/glDrawElements.xml
The key passage is: "If GL_VERTEX_ARRAY is not enabled, no geometric primitives are constructed."
This leads me to the following questions:
- None of the tutorials use
glEnableClientStatebefore callingglDrawElements. Does this mean the man page is wrong or outdated? GL_VERTEX_ARRAYwould seem to be the thing you enable if you're going to useglVertexPointer, and likewise you'd useGL_NORMAL_ARRAYwithglNormalPointer, and so on. But if I'm not using those functions, and am instead using generic vertex attributes withglVertexAttribPointer, then why would it be necessary to enableGL_VERTEX_ARRAY?