Jump to content
  • Advertisement
Sign in to follow this  
sjf

disable textures

This topic is 4542 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I’m trying to “turn off” active textures 0 and 1. I do the following to load them into a shader of mine: /* Load the cloud texture. */ glActiveTexture(GL_TEXTURE0 + 0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); glActiveTexture(GL_TEXTURE0 + 1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); But when I do the following later on, all hell breaks lose: glColor4f(0.0f, 1.0f, 0.0f, 1.0f); // This colour has no effect! /* Render the foreground. */ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_floor); // This texture has no effect! RenderStuff(); glDisable(GL_TEXTURE_2D); I’ve traced the problem to not “turning off” my first set the textures “id_cloud”! ‘cos’ if I comment out enabling my cloud textures, everything works fine. So, in short, how do I disable what I have enabled?: /* Load the cloud texture. */ glActiveTexture(GL_TEXTURE0 + 0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); glActiveTexture(GL_TEXTURE0 + 1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, id_cloud); If further explanation is required, just ask. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Just make sure that you disable all your active TMUs.


glActiveTexture(GL_TEXTURE0);
glDisable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE1);
glDisable(GL_TEXTURE_2D);


Share this post


Link to post
Share on other sites
From my experience I don't think you need to call glEnable(GL_TEXTURE_2D) when using shaders... All I do is call glActiveTexture(GL_TEXTURE0) and then bind the texture I need to use and call the texture sampler in GLSL. I am assuming you are using GLSL or VP/FP since you stated "shader"

Share this post


Link to post
Share on other sites
/* Render the foreground. */
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id_floor); // This texture has no effect!

the above 2 commands will operate on the current active texture unit ->glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE1); etc

thus u have to trace back in your code until u find what it is. theres also prolly a get command to query what it is.
to make it easy set it just before u do anything eg

glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id_floor);

and yes with shaders textures dont need to be enabled

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
/* Render the foreground. */
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id_floor); // This texture has no effect!

the above 2 commands will operate on the current active texture unit ->glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE1); etc

thus u have to trace back in your code until u find what it is. theres also prolly a get command to query what it is.
to make it easy set it just before u do anything eg

glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id_floor);

and yes with shaders textures dont need to be enabled


I am assuming I don't need to disable them either since there was not call to enable that texture unit with glEnable()?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!