Search code examples
opengl3dkotlinlwjgl

Why bind OpenGL buffer objects?


In OpenGL a general procedure is to bind a named buffer object (or vertex array object, framebuffer, ...), invoke some operations on the currently bound object and then bind some kind of "default" object:

glBindBufferObject(GL_ARRAY_BUFFER, bufferObjectName)
glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW)
glBindBufferObject(GL_ARRAY_BUFFER, 0)

(LWJGL in Kotlin)

I just discovered that there are "named" version for many functions. The example from above would become something like

glNamedBufferData(bufferObjectName, data, GL_STATIC_DRAW)

which is way more suitable in an object-oriented context.

So why use something like in the first example? Every tutorial I came upon used the first approach, so is there some performance lost or similar downsides in the "named" approach?


Solution

  • The named functions are part of the ARB_direct_state_access extension which was introduced in OpenGL 4.5. Before that only the normal methods existed.

    The main reason for using the older version is when targeting pre OpenGL 4.5 hardware. Most tutorials are also written against older versions of OpenGL.