glEnable(GL_TEXTURE_2D) - really?

Started by
2 comments, last by dpadam450 13 years, 1 month ago
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!

Advertisement
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.
http://www.opengl.org/wiki/GLSL_:_common_mistakes#Enable_Or_Not_To_Enable
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement