The way I learnt to send a texture to a shader is more or less

//Use program
//Bind texture to the texture unit to its appropriate target
glActiveTexture(GL_TEXTURE0 + texture_unit);
glBindTexture(target, textureID);
//Get the uniform location in the program and attach the texture unit
GLuint location = /*get the location somewhow*/;

However when dealing with buffers and SSBOS rather than trying to find a location through a string name, the object is declared as:

layout(std430, binding = 2) buffer texture_meta_data

For example. This means that the SSBO is to be bound at binding point 2

And then on the C++ side one does something like


To bind the object to the binding point.

How can you do the same with textures?


1 Answer 1


By using the exact same syntax as you did for SSBOs:

layout(binding = 0) uniform sampler2D texture_name;

This is a GL 4.2 feature, so if you can use SSBOs, you can use this.


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.