Jump to content
  • Advertisement
Sign in to follow this  
BobMcGee

OpenGL How to use alpha pixels in a tga file

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

I've done alpha blending before just by using glcolor4f, which is pretty easy. Now, I'm trying to utilize the alpha channel of a tga texture to help rendering. For example, say I have a sun texture where the colored sun is in the middle, and everything else around it is alpha pixels that say everything except the sun is transparent (technically you have to make two separate textures and combine them to do this). What I want to know is, what settings do I need to set (in OpenGL) in order to get this to work properly (prior to rendering the geometry with this texture)? I want the sun to be visible, but everything around the sun to not be rendered (otherwise you can see the rectangular outline, and I just want the sun to be visible). I know that my texture loading schemes are all good but the actual rendering effect is not.

Share this post


Link to post
Share on other sites
Advertisement
in art program create the sun in the sun visability in the alpha channel, white == sun visable, black == background visable
load the texture
enable blending
use glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

Share this post


Link to post
Share on other sites
Hmm that's what I have been doing. Oh well I might've been setting up the alpha channel incorrectly but at this point I'll just keep working it and eventually I'll get it, thanks for the help (that cleared up that I'm doing the programming side of it correctly).

Share this post


Link to post
Share on other sites
Quote:
Original post by BobMcGee
Hmm that's what I have been doing. Oh well I might've been setting up the alpha channel incorrectly but at this point I'll just keep working it and eventually I'll get it, thanks for the help (that cleared up that I'm doing the programming side of it correctly).


Make sure you are creating RGBA textures and not RGB. IF you were using 24-bit(RGB) TGAs before and are now trying to use 32-bit(RGBA) TGAs now then your old code may need some minor changes. Other than that zedzeek is right on. That should be about it. As long as the images is saved correctly and a texture is correctly made from it. Enable blending, set the above blending mode, and go about your normal way of things.

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!