How does glBufferData know which VBO to work on?

北慕城南 提交于 2019-12-02 06:06:00

问题


Here is the formal declaration for glBufferData which is used to populate a VBO:

void glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);

What is confusing, however, is that you can have multiple VBOs, but this function does not require a handle to a particular VBO, so how does it know which VBO you are intending?

The target parameter can be either GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER but my understanding is that you can have more than one of each of these.

The same is true of the similar glBufferSubData method, which is intended to be called subsequent times on a VBO -- how does it know which VBO to handle?


回答1:


This is a common pattern in OpenGL to bind object to a target and perform operations on it by issuing function calls without a handle. The same applies to the textures.




回答2:


OpenGL operations that use a buffer object, make use of the buffer that has been bound by the most recent call to glBindBuffer on the used target.




回答3:


glBindBuffer is a function that exposes the given buffer as bound. Such a glBufferData access it then by side-effect, through the currently bound buffer object.



来源:https://stackoverflow.com/questions/14172165/how-does-glbufferdata-know-which-vbo-to-work-on

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