Sign in to follow this  
lack the hack

where to call glDisable()?

Recommended Posts

hello everyone, i was just wondering if you were wanting to disable texture mapping after you texture map, where would you call it? whenever i call it my texture doesn't display anymore. i know the code you should use is this:
glDisable(GL_TEXTURE_2D);

i'm using win32 for my window, so should i call it inside my main message loop, or where i call initalize()? i would think i should call it at the end of my render function or something. when i don't disable texturing my color pixels get mixed up with my bitmap so the scene is really messed up. thanks for the help:-)

Share this post


Link to post
Share on other sites
Disable it when you want to render untextured objects and reenable it when you want to draw textured objects, i.e.:
void render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
drawUntexturedObject();
glEnable(GL_TEXTURE_2D);
drawTexturedObject();
drawTexturedObject();
glDisable(GL_TEXTURE_2D);
drawUntexturedObject();
}

Enigma

Share this post


Link to post
Share on other sites
As Enigma said, just place it after the objects with texture maps have been drawn, but be sure to reenable it before you try to start drawing textures again, it sounds like thats what you're forgetting.

Share this post


Link to post
Share on other sites
thanks a bunch you guys, that fixed everything

one more question:
if i wanted to load 2 texture files into memory and texture map them onto different quads, how would i do that? i loaded 2 files into memory and have a separate .h file and separate function for each, but when i call their function, it only displays one of the texture files. how do i make sure that when i texture my ground, the sand texture shows up, and the background texture shows up in the background instead of the sand data?

thanks again

Share this post


Link to post
Share on other sites
Quote:
Original post by lack the hack
thanks a bunch you guys, that fixed everything

one more question:
if i wanted to load 2 texture files into memory and texture map them onto different quads, how would i do that? i loaded 2 files into memory and have a separate .h file and separate function for each, but when i call their function, it only displays one of the texture files. how do i make sure that when i texture my ground, the sand texture shows up, and the background texture shows up in the background instead of the sand data?

thanks again
Bind the background texture and render your background, then bind the sand texture and render your sand.
glBindTexture(GL_TEXTURE_2D, bgTexName);
RenderBackground();

glBindTexture(GL_TEXTURE_2D, sandTexName);
RenderSand();

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this