Sign in to follow this  

glEnable(GL_TEXTURE_2D) - really?

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

This might sound max stupid but i have a small query.




When i render something using shader, i don't use glEnable(GL_TEXTURE_2D) .

But when i render my GUI it looks it won't render without enabling TEXTURE_2D (fixed pplne), so the question is - should i go and render the gui with shader to get rid of

glEnable(GL_TEXTURE_2D) call per frame basis? Or there is something else i forgot about...







Thanks!

Share this post


Link to post
Share on other sites
Hello donmof,

I suggest you try multitexturing on your shader and see what happens, that will give you a good knowledge on what is going on in OGL state machine.

As for the answer to your question, glEnable( GL_TEXTURE_2D), enables sampler 0 within the state machine. So for instance whenever you bind something it will only go to sampler 0 within the pipeline. On a fixed pipeline behavior this means more or less: texturing to first coords with sampler 0. On a programable pipeline you do assume texture sampler is 0 only (in your case), and therefore is straightforward. If you try what I suggested you will see same behavior on both shader and fixed pipeline for multitexturing, and see what happens really (as you will need to specify what sampler are you binding what texture).

Cheers.

Share this post


Link to post
Share on other sites
Assuming you are single texturing your gui, you can just enable texturing for the active texture unit 0. Just keep it enabled for your whole program. You only need to enable/disable if multitexturing in the fixed function because the highest unit takes precedence.

Share this post


Link to post
Share on other sites

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