OpenGL ES 2.0: Commands required just before glDrawElements with VBO [closed]
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 gl开发者_开发百科BufferData
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.
glDrawElements
submits geometry. If you're using VBOs then it uses entries in the currently bound GL_ELEMENT_ARRAY_BUFFER
to index entries in the relevant portions of the GL_ARRAY_BUFFER
or 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 call glDrawElements
you copy and paste that line to appear twice, all your geometry will be drawn twice as many times as before.
精彩评论