Sign in to follow this  
sjf

disable textures

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
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

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