I’ve setup a Vertex Buffer Object (VBO) with vertex and index data. I’ve also created a GLprogram to use custom shaders, so I call glUseProgram within my code.
My vertex data changes every frame, so I’ve supplied GL_STREAM_DRAW to my two glBufferData calls (one for vertex data, one for indices).
I use glBufferSubData to modify regions of my vertex data when they change. At each frame I want to draw from the first vertex to the Nth, with N being a changing value.
My question is: which commands must I call every time that I call glDrawElements? Ideally I’d like to simply call glDrawElements on its own in each frame, for performance reasons.
I’m poring over the book “OpenGL ES 2.0 Programming Guide” but nowhere does it tell me which commands I must use every time I draw, and which I need to call only once.
glDrawElementssubmits geometry. If you’re using VBOs then it uses entries in the currently boundGL_ELEMENT_ARRAY_BUFFERto index entries in the relevant portions of theGL_ARRAY_BUFFERor buffers bound for each attribute.If you don’t change any other bindings then is no need to repeat any call other than
glDrawElements. If, where you currently callglDrawElementsyou copy and paste that line to appear twice, all your geometry will be drawn twice as many times as before.