PDA

View Full Version : Turning off glActiveTextureARB



LostInTheWoods
01-21-2003, 05:01 PM
I am currently attempting multitexturing. I set up part of a 3d scene using glActiveTextureARB, and called glEnable(GL_TEXTURE_2D) just after. But now i am getting some strange results when i want to go back to my 2D GUI setup. If I call glActiveTextureARB and disable texture 2d right afterwards, i get NO textures in my gui. If i call a glenable texture 2d inside the gui calls, i get colors but not textures. Is there a way to turn off the glActiveTextureARB?? or am i simply not doing something right??

Bob
01-21-2003, 11:37 PM
You just disable the texture units you don't need, that's all.

Tom Nuydens
01-22-2003, 12:43 AM
Also make sure that when you disable your second/third/... texture unit, you switch back to unit 0 before rendering single-textured geometry. E.g.



glActiveTexture(GL_TEXTURE1);
glDisable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, yourGUItexture);
// Now render stuff.

-- Tom

newt
01-22-2003, 01:44 AM
It helps to think of unit 0 as the default active texture.Consequently,

glActiveTextureARB(GL_TEXTURE0_ARB);

and

glClientActiveTextureARB(GL_TEXTURE0_ARB);

are implicit when writing non-multi-textured
applications.

LostInTheWoods
01-22-2003, 04:22 AM
Ok, so maybe my problem when i go back to the GUI is that i also call...
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);
Should i "never" disable the first texture? Could this be causing my problem? But if i do disable it,would calling glEnable(GL_TEXTURE_2D) fix that, cause when i do that, i only get colors. (Sorry i would simply check to see what works, but im currently working at a computer that dosnt have multitexturing, and ownt be able to check it till this evening)

knackered
01-22-2003, 04:31 AM
Disable all available texture units, by doing this:



for (int i=0; i<MAXTEXTUREUNITS; i++)
{
glActiveTextureARB(GL_TEXTURE0_ARB+i);
glDisable(GL_TEXTURE_2D);

glClientActiveTextureARB(GL_TEXTURE0_ARB+i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
glClientActiveTextureARB(GL_TEXTURE0_ARB);

then, if your gui text requires texturing (which I assume it does, you probably have each character stored in a texture), do this:-
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);

That will definitely work.

LostInTheWoods
01-22-2003, 06:36 AM
Ok i think i found my problem. I wasnt disabling the glClientActiveTextureARB. So it must have been using the same thing in my gui. What i am doing now, is i enable texture 2D when the program loads. When i go to my game, i enable all the textures needed, then diable ALL of them. Then when i go back to my gui, i simply call glEnable(TEXTURE_2D) again, hopefully that will work. If not i will simply re enable the first texture unit when i go to my gui.