Sign in to follow this  

transparent background

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

there is a sprite which is a tga file with alpha channel. it is drawn with transparent background but when load it to Open Gl and try to use it - its background doesn't appear transparent. why? ++could anyone provide a link to good and informative article on sprites. special interest : 2D sidescrollers. thanx a lot

Share this post


Link to post
Share on other sites
Assuming your image loading code is providing the alpha as a fourth channel, all you'll need to do is enable blending and provide a suitable blend function, eg

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

then render your sprite as before.

Share this post


Link to post
Share on other sites
thanx for reply. it was useful.

would like to share some ideas and explain my dismay. i was using a tga loader which reckoned it was able to load all kinds of tga files : 24,32 bit + RLE. but i noticed it could only handle tga files that were of a pretty large size (>=100 Kb).
does anybody know why?

Share this post


Link to post
Share on other sites
I think you should write your own TGA loader. You can also check nehe.gamedev.net for various tutorials on loading files.
And I would go for alpha testing, not alpha blending, when it comes to transparency.

Share this post


Link to post
Share on other sites
Quote:
Original post by Raduprv
And I would go for alpha testing, not alpha blending, when it comes to transparency.

It totaly depends on the effect you wnat. If you need very shap edges you use alpha testing, but if you need smooth edges use alpha blending (can be combined with testing for speed-up).

Share this post


Link to post
Share on other sites

This topic is 4777 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this