A few years ago I asked a question about the semantics of texture units and shader2D uniform variables. The answers I got were rather rigid in their outlook:
https://www.opengl.org/discussion_bo...-Mapping-Units
I gave up then, but I'm back.
I'm looking for a 'clean' way to abstract my code away from explicitly assigning texture units (GL_TEXTURE3 etc.) to sampler2D variables. I am using an Nvidia GTX960 and OpenGL reports it has just 4 texture units. The 0th texture unit is reserved for the fixed pipeline so there are really only three available. If I wish to use various sampler2D GLSL uniform variables I, rather obviously, don't care which texture unit they employ. What methods are commonly used to abstract away the necessary relationship?
I'd like to have some OpenGL code to find a 'free' texture unit anytime I want to address a GLSL shader2D variable. When one writes in C there is no need to know how many registers the CPU has or the assignment of variables to them. The compiler does all of that. I can't change OpenGL or GLSL but I can attempt to hide the need to make manual 'register' assignments.
There is a level of indirection/assignment that is getting in the way of my writing a 'clean' approach.