1
$\begingroup$

I'm developing a general Mesh class with the help of LearnOpenGL. In the example he creates a class which assumes that you want to generate a VAO, VBO, and an EBO but I don't usually use EBOs so I only want to generate an EBO under certain circumstances. So if I decide not to generate an EBO then I want to set my EBO to a number which cannot be generated by glGenBuffers.

// Draw Mesh
glBindVertexArray(this->VAO);

if(EBO not in range generated by glGenBuffers)
    glDrawArrays(GL_TRIANGLES, 0, numVertices);
} else {
    glDrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_INT, 0);
}

glBindVertexArray(0);

My question is what is the range that a buffer object's name can be in?

$\endgroup$
2
$\begingroup$

According to the OpenGL spec, any integer other than zero can be a potential name. Zero is the only value that's guaranteed not to be an object name.

Relevant quote from the spec:

2.6.1.1 Name Spaces, Name Generation, and Object Creation

Each object type has a corresponding name space. Names of objects are represented by unsigned integers of type uint. The name zero is reserved by the GL; for some object types, zero names a default object of that type, and in others zero will never correspond to an actual instance of that object type.

Names of most types of objects are created by generating unused names using commands starting with Gen followed by the object type. For example, the command GenBuffers returns one or more previously unused buffer object names.

$\endgroup$
  • $\begingroup$ Do you mean any integer or any unsigned integer? $\endgroup$ – Archmede May 14 '17 at 20:20
  • 2
    $\begingroup$ @Archmede The type of names is unsigned integer, so that's what I mean. $\endgroup$ – Nathan Reed May 14 '17 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.