Problem Binding 3D texture?

My app creates multiple 3D textures and applies them procedurally to different pieces of a model. Funny thing is the 3D texture applied is always the last one created!

I traced the problem and it seems that BindTexture(GL_TEXTURE_3D, id) is failing during the texture creation with INVALID_OPERATION!

Pseudo code:
[texture creation]
GenTextures( tex_count, id_array);
loop tex_count
Enable(TEXTURE_3D)
BindTexture(TEXTURE_3D, id_array[i]);
TexImage3D(TEXTURE_3D, …);

Is there something silly I’m forgetting to set/reset? It seems to fail for the first few but always succeeds on the last volume texture…

Jay

Just one clarification, it’s actually Binding the first volume texture correctly. It’s all the subsequent ones that fail.

Never mind - I solved the problem. Apparently some condition caused the Enable() call to use TEXTURE_2D instead!

The only reason why the TEXTURE_3D showed up in the first place was probably the TexImage3D() call, which I’m assuming not only loads the image data but sets the TEXTURE_3D to it as well.