<p>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.</p>
<p>Relevant quote from <a href="https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf" rel="nofollow noreferrer">the spec</a>:</p>
<blockquote>
<p><strong>2.6.1.1    Name Spaces, Name Generation, and Object Creation</strong></p>
<p>Each object type has a corresponding <em>name space</em>.  Names of objects are represented by unsigned integers of type <code>uint</code>.  The name zero is reserved by the GL; for some object types, zero names a <em>default object</em> of that type, and in others zero will never correspond to an actual instance of that object type.</p>
<p>Names of most types of objects are created by <em>generating</em> unused names using commands starting with <strong>Gen</strong> followed by the object type.  For example, the command <strong>GenBuffers</strong> returns one or more previously unused buffer object names.</p>
</blockquote>

CC BY-SA 3.0
2017-05-14T20:20:52.873Z
Do you mean any integer or any unsigned integer?
Archmede
CC BY-SA 3.0
2017-05-14T20:32:22.047Z
@Archmede The type of names is unsigned integer, so that's what I mean.
Nathan Reed
CC BY-SA 3.0
2017-05-14T20:10:00.883Z
2017-05-14T20:10:00.883Z
2020-06-18T08:32:12.800Z
Nathan Reed
<p>I'm developing a general Mesh class with the help of <a href="https://learnopengl.com/" rel="nofollow noreferrer">LearnOpenGL</a>. 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 <code>glGenBuffers</code>.</p>

<pre><code>// Draw Mesh
glBindVertexArray(this-&gt;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);
</code></pre>

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

<opengl><buffers>
Range of integers returned by glGenBuffers?
Archmede
# Range of integers returned by glGenBuffers?

(Asked by: username_0 on 2017-05-14)

I'm developing a general Mesh class with the help of [LearnOpenGL](https://learnopengl.com/). 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?

**Tags:** opengl, buffers


---

## 1 answers

### Answer by username_1 on 2017-05-14. Score: 2 | Accepted answer

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](https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf):

> **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.

> **Comments:**
> **username_0**: Do you mean any integer or any unsigned integer?  
> **username_1**: @username_0 The type of names is unsigned integer, so that's what I mean.  

---

