Skip to main content
1 of 4
Makogan
  • 1.8k
  • 14
  • 31

Can you avoid querying for a texture location in OpenGL?

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*/;
glUniform1i(location,texture_unit);

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

layout(std430, binding = 2) buffer texture_meta_data

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

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

glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, SSBOID);

To bind the object to tha bidning point.

How can you do the same with textures?

Makogan
  • 1.8k
  • 14
  • 31