Jump to content
  • Advertisement
Sign in to follow this  
ChrisRX

Transparent png not transparent with sdl_image

This topic is 2697 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 created a png in inkscape with a transparent background, and when I load up the png it has transparency. But when I load it into my game using SDL_image it appears white where it should be transparent. Any ideas? [Edited by - ChrisRX on January 1, 2008 3:02:34 PM]

Share this post


Link to post
Share on other sites
Advertisement
Doesn't that set the alpha of the entire surface though? I've got a png stored with transparent parts, I don't want it all transparent. Thanks anyway

I found it's actually because I'm optimising when I load the image with SDL_DisplayFormat. If I get rid of this it works fine. Is there any way to get the transparency to work with SDL_DisplayFormat?

Share this post


Link to post
Share on other sites
I didn't want to create new topic because i have same problem and SDL_DisplayFormatAlpha didn't solve the problem.
I load PNG image (alpha included) with IMG_load.

Then im creating opengl texture like that


glGenTextures(1,&textureid);

glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ) ;
glBindTexture(GL_TEXTURE_2D, TextureID);

glTexImage2D(GL_TEXTURE_2D, 0, mode, surface.w, surface.h, 0, mode, GL_UNSIGNED_BYTE, surface.pixels);
// these affect how this texture is drawn later on...
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);


And as result i get white color instead of transparency.

This is my Opengl alpha settings:

glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);



What should i do to make it work?


TIA.

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!