Where r, g, b, and texture are passed in as arguments. If I use GL_TEXTURE0, the texture displays fine. If I use GL_TEXTURE1 through GL_TEXTURE3, the texture is a single washed out color (The color depends on the color of the texture). If i use anything beyond GL_TEXTURE4, the image is pure white.
Nothing else has changed in between tests. What gives?
The fixed function texture environment pipeline applies a math function to the value sampled from the each texture in order. That is, it does the texture environment operation from GL_TEXTURE0, then from GL_TEXTURE1, then from GL_TEXTURE2, etc. Each operation feeds into the next.
If you really want the flexibility to use arbitrary texture units however you want, you will need to use shaders.
If i use anything beyond GL_TEXTURE4, the image is pure white.
That’s probably because GL_MAX_TEXTURE_UNITS is 4 for your implementation. That means you can’t used fixed-function texture environment logic with more than 4 textures in a single pass.
Ive read (on another thread here) that using shaders will give you access to the full range, but is there any way to check what that range is?
GL_MAX_TEXTURE_IMAGE_UNITS. That’s the maximum number across all shader stage. Each shader stage has its own limit, but this enum gets you the sum total of all shader stages.
In general, for DX9-class hardware, the limit is 8 for fragment shaders and 4 for vertex shaders. In DX10 and above, it’s 16 for each stage.