Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


glTexEnvi using GL_REPLACE?

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

From the OpenGL Blue Book, the glTexEnvi() function definition is the following: void glTexEnvi(GLenum target, GLenum pname, GLint param) PARAMETERS . . . param - Specifies a single symbolic constant, one of GL_MODULATE, GL_DECAL, or GL_BLEND. but in the book "OpenGL Game Programming, I see glTexEnvi() used with GL_REPLACE in the "param" parameter lots of times. The first time I noticed it, I thought "that''s probably an error, if I check the source it should be corrected" and so I did... but it was just the same as in the book. And when I tried to compile it, I expected an error but it runs just fine! Can someone explain me why and what does that parameter do? Thanks Raúl

Share this post

Link to post
Share on other sites
GL_REPLACE basically tells the renderer to skip the current color and just use the texel colors--if you use GL_MODULATE then if you make a call to glColorx() your textures will be filtered to that color too.

i.e. if you call glColor3f(0.0, 0.0, 1.0) and then draw a texture triangle, the texture will only contain it''s blue elements. The same triangle drawn after you engage GL_REPLACE will appear in it''s "true" colors regardless of the current color.

At least that''s my understanding.

Share this post

Link to post
Share on other sites
So for every fragment of a polygon needs a color.
The polygon starts with a colour C.
The texture has a colour T.
And F is what the color ends up as.

The polygon ends up the colour T.
F = T

The polygon''s original colour and the texture colour are multiplied together.
F = CT

This is just like GL_REPLACE, unless you specify an alpha for your texture. Then part of the original polygon colour is made to shine through the texture. Kind of like a bad wallpaper job where you can see the paint behind it.

This is a bad wallpaper job all the time.

Hope this explains it. This is kind of a simplified explanation, but check this link for the exact mathematical equations:

And you may be look in version 1.1 of the bluebook and version 1.2 of the redbook.

Somebody correct me if I''m wrong, but GL_REPLACE may have been added in the 1.2 spec.


Share this post

Link to post
Share on other sites
Thanks for your explanations.

Screaming Lunatic, I thought about that (GL_REPLACE being added in the 1.2 spec) but since I don''t have access to the more recent versions of the book...

Well, thanks again, everybody!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!