Probably trivial Opengl question..but

Posts: 321
Joined: 2004.10
Post: #1
In the Red Book I see a line of code:


what gives with glTexEnv{if} definition. Aren't the three GL_xxxx above
enums so wont shouldn't it be glTexEnvi(....)?

Also, does the glTexEnv?() always need to be performed before a

Or can this be updated dynamically before each


Quote this message in a reply
Posts: 1,140
Joined: 2005.07
Post: #2
glTexEnvi probably would be better, but I think it's designed to work with the floating point versions as well. It can be called at any time, not just before loading the texture.
Quote this message in a reply
Posts: 133
Joined: 2008.05
Post: #3
"Better"? It doesn't matter. The f is around for the glTexEnvfv, where you can supply an RGBA value to the params when using GL_TEXTURE_ENV_COLOR. Using f or i for the singular GL_TEXTURE_ENV_MODE does not matter at all.

As for when to call it, this operation does not modify the texture at all. So calling it before loading the texture isn't going to do anything if end up changing it. You should call it after you activate a texture unit(glBindTexture(), glActiveTextureARB()) and most likely return it to GL_MODULATE when you are done, since that is the default.

Read the man page.
Quote this message in a reply
Posts: 1,140
Joined: 2005.07
Post: #4
Better for that case, I mean. (aka: when you're passing in an enumerated value)
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #5
Calling the f version assumes that (GLenum)(float)GL_X == GL_X, which certainly should be true of any IEEE float as long as GL_X has fewer than 23 significant bits. As far as I know, GLenums are all 17 bits or less, so it's OK for now.

I'd still call the i version, myself, just to be safe. If nothing else, it's more efficient Wink
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL transparency question? MrPenguin9 9 8,033 Apr 20, 2010 07:25 AM
Last Post: Beast
  OpenGL question Leroy 2 3,518 Apr 28, 2007 04:48 PM
Last Post: BinarySpike