Jump to content
  • Advertisement
Sign in to follow this  
jaymzjc

OpenGL Using a texture combiner to tint a sprite

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

Can anyone give me any pointers on how I would use a texture combiner to tint a textured poly using the fragment color and texture alpha? The way I'm thinking this will work will be to use the vertex color to specify the RGB component and use the textures alpha to specify the alpha component. Since I'm rendering sprites I have to use the alpha from the texture or I would get a solid colored quad. I'm stuck with OpenGL ES 1.1 so shaders are out of the question. Using the default OpenGL setup I can "tint" the texture using a non-white vertex color. This partially works but I would like to be able to make the sprites render solid colors, red, white, green, etc. I don't have much experience with texture combiners so I'm still trying to get my head wrapped around them. This is what I tried: glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_PRIMARY_COLOR); glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE); The above did correctly use the primary color but the alpha values are coming out semi-transparent where they should be fully-transparent. I'm guessing this is because the vertex color has a alpha of 1.0 and is still getting blended with the texture alpha but I'm not sure what to do to fix that.

Share this post


Link to post
Share on other sites
Advertisement
There are a few calls you are missing such as
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, ...)
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, ...)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, ...)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, ...)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, ...)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, ...)

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!