OpenGl Texture unit problem

I have these two 3D textures that are being sent to the fragment shader and are rendered perfectly OK.
But there is a problem, As soon as I even create another texture (it’s a 1D texture), a black screen is being rendered instead of the correct former result.

About this 1D texture, I’m not even sending it to the fragment shader. The minute I call glTexImage1D(…) the black screen shows up. I comment this line and it goes away!!And the two textures are rendered.

I figured there has to be some kind of problem with texture units. Because when I run the application with gDebugger, the texture unit of one of 3D textures is THE SAME as the one assigned to the 1D texture.

I did not assign any texture unit to the 1D texture, I just created it. Apparently texture unit GL_TEXTURE0 is being automatically assigned to the 1D texture. The weird part is that although I use GL_TEXTURE2 and GL_TEXTURE3 for the 3D texture, one of them is being bound to GL_TEXTURE0 as a result of calling glTexImage1D!

Here is an output from the textures list window of gDebugger:

Texture 1 (unit 2 ,bound3d)-enabled
Texture 2 (unit 0 ,bound1d)
Texture 3 (unit 0 ,bound3d)-Enabled (unit 3,bound3D)-enabled

Can you please explain to me why is this happening?

So why don’t you use TEXTURE0 and TEXTURE1 instead of 2 and 3?

PS: texture units can’t be enabled or disabled. They are always enabled.

Are you absolutely sure your program logic is binding the right textures to the right units + the uniforms are correctly assigned to the correct texture units?

From the OpenGL spec:

But I guess it shouldn’t apply if you aren’t actually trying to access the 1D texture in the shader. Are you getting any error messages reported?

And as V-man said, whether texture units are enabled/disabled is ignored by shaders.