Jump to content
  • Advertisement
Sign in to follow this  
Runt888

Specifying Constant in glTexEnv

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

When using the texture_env_combine extension with the CONSTANT_ARB source, how is the value of the constant specified? Thanks. Kelly

Share this post


Link to post
Share on other sites
Advertisement
GLfloat my_constant_color[4] = { /* fill in RGBA color */ };
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, my_constant_color);

Share this post


Link to post
Share on other sites
Ah...duh...

Maybe you can tell me why this isn't working as expected. I basically want to blend two textures using a single opacity value between 0.0 and 1.0. The base texture is in texture unit 0, and the top texture is in texture unit 1.

Here's the TexEnv commands for texture unit 0 (tex unit 0 is active, texturing is enabled, and the first texture is bound):
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_REPLACE );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );

Here's for the second texture unit.
tFloat color[4] = { 0.0, 0.0, 0.0, mBillboard->getSurfaceOpacity() };
glTexEnvfv( GL_TEXTURE_2D, GL_TEXTURE_ENV_COLOR, color );

glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );

glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_CONSTANT_ARB );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA );

Do you see anything wrong with this setup? All I'm getting is the first texture. Thanks for any help!

Kelly

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!