Yeah, I have glGetAttribLocation() calls for other variables (coord3d,…) in the shader right before the glGetUniform(). These work just fine. The shaders link and compile successfully as well, I’m evaluating the log every time.
Not sure what the issue with the uniform location is, but a sampler2D variable is not an integer in disguise even though the application uses glUniform1i to assign a value. Inside the shader the variable has an opaque type that you can not compare to integers, that can not participate in arithmetic (adding two sampler2D variables does not work) or pretty much anything else except being passed to one of the texture access functions.
Even if you use a separate uniform variable to indicate if a texture is available the situation is slightly iffy, because (at least certain generations of) hardware can not really execute conditionals. Instead it always executes both branches and discards the result of the branch not taken - so there is always the attempt to read from the texture even if your variable says you don’t have one. That can lead to trouble if no texture us bound. Aggressive optimization may be able to figure out that the uniform is false and thus it can kill the complete branch, but I believe that is not required by GLSL and relying on optimizations to happen for correctness is a bit of a slippery slope
Well, just to let anyone who’s interested know - After renaming the variable and rewriting my shader (maybe I wasn’t really using it after all and the use was optimized out anyway) I have no more problems. Don’t really know what that was about, thanks a lot anyway to y’all.