Function familiesfamily

glGen*

Reserve names (GLuint numbers) for new objects; the object itself appears at the first bind.

Signature

void glGen{Buffers|VertexArrays|Textures|Framebuffers|Renderbuffers|Queries}(GLsizei n, GLuint *ids);

How it works

OpenGL objects are referred to by names: plain unsigned integers. glGen* hands out n unused ones, and 0 always means "no object". A freshly generated name is only reserved: the object is created the first time it is bound (glBindBuffer, glBindTexture…), and only then does it have a type.

That is why a DSA call on a name that was generated but never bound fails. The glCreate* family (GL 4.5) creates real objects at once and is the modern choice.

Reading the name

Buffers, Textures…
The kind of object, always plural: the function can make several at once.
n, ids
How many names, and the array that receives them (&id for one).

Functions in this family

Example

example.cpp
1GLuint vbo, vao;
2glGenBuffers(1, &vbo);        // name reserved
3glGenVertexArrays(1, &vao);
4glBindVertexArray(vao);       // VAO created here
5glBindBuffer(GL_ARRAY_BUFFER, vbo);   // buffer created here