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

喜夏-厌秋 提交于 2019-12-11 15:18:42

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7302562/opengl-es-2-0-commands-required-just-before-gldrawelements-with-vbo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!