I have an image and a sampler declared in a shader as follow

layout(binding = 5) uniform isampler2D heightmap;
layout(binding = 3) uniform writeonly uimage2D info;

Which are correctly bound using the following code

glBindTextureUnit(5, heightmapId);
glBindImageTextures(3, 1, &infoId);

For introspection purposes, I am trying to retrieve the binding points of these objets, 5 and 3, but I didn't find any way to do this for uniforms. Is it possible using the API?

I first tried to use glGetProgramResourceIndex, since it worked with storage buffers, but it doesn't the results are get are incorrect, as if the explicit binding was ignored.

I then looked at glGetProgramResourceiv, but the binding related enums are only available for storage buffers and atomic counters.


1 Answer 1


The binding value for uniforms of opaque types is, from the perspective of the OpenGL API, the uniform's value. You set it by using glProgramUniform1i.

As such, you query it by querying the value of the uniform with glGetUniformiv.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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