Skip to main content
gamedev.net
🔒 Locked

disable textures

Started by sjf 3 replies 4.2k views
Original Post
sjf
sjf
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!
NLDEV
NLDEV
Just make sure that you disable all your active TMUs.

glActiveTexture(GL_TEXTURE0);glDisable(GL_TEXTURE_2D);glActiveTexture(GL_TEXTURE1);glDisable(GL_TEXTURE_2D);
MARS_999
MARS_999
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"
zedzeek
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
MARS_999
MARS_999
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()?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.