Sign in to follow this  

Transparent png not transparent with sdl_image

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
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

[code] glGenTextures(1,&textureid);

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...

And as result i get white color instead of transparency.

This is my Opengl alpha settings:

[code] glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5);[/code]

What should i do to make it work?


Share this post

Link to post
Share on other sites
[quote name='samuraicrow' timestamp='1199201514' post='4131033']
See [url=""]SDL_SetAlpha[/url] for information about alpha-channel blitting.

Yes I agree. You have a very insightful post my friend.

Share this post

Link to post

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