ive just started glsl in my engine, and looking att he glsl specs, and see some great stuff automatically bound such as light info, matrices, and the like, but i see nothing like this for textures?
did i just miss it is there a reason they have not done this? because this means i need to parse my shader, and search for some “sampler*” keyword and do it myself…
EDIT:
Right now there’s no possibility to get all samplers out of a program object by calling glActiveUniform because samplers are threated as ints and so you can’t say if an uniform is a sampler or an int. But there should be a GLSL specification update in the next time where this problem is solved.
Without bordering at which this texture unit the sampler is bound.
Then in you app you can choose where to bind your texture. If your texture has to be bound at a specific texture unit then simple pass that texture unit using glUniform1i to tell the shader where to sample.
indeed, this method does seem better as it decouples the texture unit used and the shader instead of forcing you to always use a certain texture unit for a certain effect (and as the number of texture units increase this will help with resource wastage)