开发者

OpenGL ES 2.0: Commands required just before glDrawElements with VBO [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜