Sign in to follow this  

Disabe Textures in GLSL

This topic is 4247 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

I am writing a shader to do per fragment lighting. Everything is working well except that I can't turn textures off. App Code: glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture.TexName()); DrawTorus(...); glDisable(GL_TEXTURE_2D); DrawTorus(...); When rendering with the fixed pipe, I get a textured torus and a torus with the previously defined material. in my shader, I get two textured tori. I tried adding the line glBindTexture(GL_TEXTURE_2D, 0); before my second torus call, but my shader spit out a black torus. here is the code in my fragment shader, ala Rost: // calculate diffuse with multiple lights diffuse *= texture2D(Tex, gl_TexCoord[0].st); I would like to query the current state from my shader to determine if 2D textures are enabled. Any ideas? TIA J

Share this post


Link to post
Share on other sites
You should be able to query the state of the FF setup in a shader, but I forget the exact syntax (and I havn't got my orange book on me). However you might want to look at this.

Share this post


Link to post
Share on other sites
glEnable(GL_TEXTURE_2D); + disable are ignored with glsl, ie u cant enable or disable texture units (if u dont wanna use one then dont access it)

Quote:
I would like to query the current state from my shader to determine if 2D textures are enabled.

u will have to pass this info to the shader yourself as a uniform

Share this post


Link to post
Share on other sites
I too faced with the same problem of accessing texture state in the shader. For the time being i'm using uniforms for that purpose.

Share this post


Link to post
Share on other sites

This topic is 4247 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.

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