DebuggingGL 4.3

glObjectLabel

Gives an OpenGL object a human-readable name for debug messages and tools.

Signature

void glObjectLabel(GLenum identifier, GLuint name, GLsizei length, const char *label);

How it works

Messages and tools like RenderDoc will say "texture 'Brick albedo'" instead of "texture 17". It costs nothing at runtime, so label everything you create.

Parameters

identifierGLenum

Object type: GL_BUFFER, GL_TEXTURE, GL_PROGRAM, GL_SHADER, GL_VERTEX_ARRAY, GL_FRAMEBUFFER…

nameGLuint

The object's ID.

lengthGLsizei

Label length, or -1 if null-terminated.

labelconst char *

The name.

Tips & pitfalls

  • With the old glGen* API the object must have been bound once before it can be labeled.

Example

example.cpp
1glObjectLabel(GL_TEXTURE, albedo, -1, "Brick albedo");
2glObjectLabel(GL_BUFFER, vbo, -1, "Cube VBO");
Official Khronos documentation