transparent background

Started by
3 comments, last by _DarkWIng_ 19 years, 5 months ago
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
Advertisement
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.
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?
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.
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).
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement