Jump to content
  • Advertisement
Sign in to follow this  
Pemaden

Why must I use glTexEnvf

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

Hey guys, I'm not sure I entirely understand what the command 'glTexEnvf' is doing. My book does not mention using it, and most texturing tutorials also don't mention it. I don't remember why I finally ended up putting it into my code, but now that I'm trying to load multiple textures, I realize that when i remove that function, my textures don't show up. So my question is, why is this one command making or breaking my program when no one else seems to use it much. Here is my code, I don't know if it would help.
	glGenTextures(1, &texture_tgatitle);
	glBindTexture(GL_TEXTURE_2D, texture_tgatitle);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tgatitle->width, tgatitle->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, tgatitle->pixelData);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

Share this post


Link to post
Share on other sites
Advertisement
It sets up the texture environment mode on the texture unit.
Sadly, there are many people that seem to think it is bound to the texture object itself so every time they create a texture, they shuve a glTexEnv call after the glTexParameter calls.

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
basically means ignore the primary color source and just send the texels down the pipe. Read the specification on opengl at opengl.org

I think the default mode is GL_MODULATE, which means multiply texels with the primary color.

Share this post


Link to post
Share on other sites
Of course, all this is merely of historical interest, since those nice little things called shaders came into existance...

So yeah, glTexEnvf was used to configure the fixed function pixel pipeline. It was inflexible, unintuitive and limited. Fortunately, it's not needed anymore nowadays. Good riddance.

Share this post


Link to post
Share on other sites
Thanks V-man, that default setting appears to be the exact problem. I had the primary color is as black, so I guess any texels multiplied with black would always give me black. I changed the primary color, and sure enough the texture shows without that command.

Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!