Reputation: 107
I found the following code:
glGenBuffers(1, &m_posVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_posVBO);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glVertexAttribPointer(particle_attributes::POSITION, 4, GL_FLOAT, GL_FALSE,0,0);
glEnableVertexAttribArray(particle_attributes::POSITION);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &m_colorVBO);
glBindBuffer(GL_ARRAY_BUFFER, m_colorVBO);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glVertexAttribPointer(particle_attributes::COLOR, 4, GL_FLOAT, GL_FALSE,0,0);
glEnableVertexAttribArray(particle_attributes::COLOR);
glBindBufferARB(GL_ARRAY_BUFFER, m_posVBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, m_vPos, GL_DYNAMIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER, m_colorVBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, m_vCol, GL_DYNAMIC_DRAW_ARB);
glBindBuffer(GL_ARRAY_BUFFER, 0);
I wonder why both glBufferData()
and glBufferDataARB()
are called respectively with one unique VBO, and what does value zero represent in glBindBuffer(GL_ARRAY_BUFFER, 0)
?
Upvotes: 1
Views: 3638
Reputation: 54652
glBufferDataARB()
and glBufferData()
serve the same purpose. The ARB
in the first form indicates that the entry point is part of an extension approved by the OpenGL ARB (Architecture Review Board). The second form is part of the standard OpenGL specification.
The common process is that new OpenGL features are first provided as extensions. They can then go through various stages:
NV
as part of their name.EXT
in their name.EXT
is replaced by ARB
.In your example, glBufferDataARB()
was part of the ARB_vertex_buffer_object extension. This functionality then became part of standard OpenGL with version 1.5. Which was a long, long time ago (July 29, 2003).
This means that for any version 1.5 and newer, you can and should use glBufferData()
. There is absolutely no reason to use glBufferDataARB()
in this case.
Mixing standard and extension entry points for the same functionality is potentially problematic. In some cases, functionality is adopted as standard exactly the way it was defined in the corresponding extension, and the two are equivalent. But in other cases, their might be some slight adjustments in this process, or there were even multiple extensions for similar functionality that were consolidated while the functionality was added to the standard. In those cases, mixing standard and extension entry points may not work.
In summary: Don't use the extension (ARB
) form if your OpenGL implementation has standard support for the functionality. And never mix standard and extension forms of the same functionality.
For the second part of your question:
glBindBuffer(GL_ARRAY_BUFFER, 0);
unbinds the previously bound buffer. Picture it binding a "null" buffer, similar to the way you use null pointers in C/C++ to indicate that the pointer does not point to an object.
Upvotes: 7