Home > Software engineering >  Why does glObjectLabel only fails for GL_TEXTURE?
Why does glObjectLabel only fails for GL_TEXTURE?

Time:10-08

Using OpenGL 4.3 with a debug context, I am able to label programs, shaders, vertex arrays and vertex buffers.

However, I am not able to label textures and get the following error in my callback:

Source: DebugSourceApi
Type: DebugTypeError
Id: 1011
Severity: DebugSeverityHigh
Message: glObjectLabel failed because (depending on the operation) a referenced binding point is empty; a referenced name is not the name of an object; or the given name is otherwise not valid to this operation (GL_INVALID_VALUE)

If that's of any importance, I do use OpenTK library.

This is the code block where the error happens:

GL.GenTextures(1, out Texture);
const string labelTEX = "ImGui Texture";
GL.ObjectLabel(ObjectLabelIdentifier.Texture, Texture, labelTEX.Length, labelTEX);

Question:

Why does glObjectLabel work for everything but GL_TEXTURE?

CodePudding user response:

In your example code, you have not created a texture. You have created the name for a texture. In order to create an actual texture object, you need to bind this texture name to the context.

If your other code didn't bind the object before giving it a name, you probably got away with it because most objects are not typed. Textures are special in that, in order to create them, you have to give them a type (the first parameter in glBindTexture). And that type becomes a part of the texture object itself, specifying how it may be used (and not used) in the future.

Alternatively, if DSA functionality is available to you, just switch to glCreate* functions and move on.

  • Related