Transparent png not transparent with sdl_image
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]
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?
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?
The documentation to SDL_DisplayFormat says that if you want to use the Alpha channel, you should use SDL_DisplayFormatAlpha.
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
And as result i get white color instead of transparency.
This is my Opengl alpha settings:
What should i do to make it work?
TIA.
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.
Nvm.
I had use masks and now it's working.
As you see, transparent road arrows.
I had use masks and now it's working.
As you see, transparent road arrows.
See SDL_SetAlpha for information about alpha-channel blitting.
Yes I agree. You have a very insightful post my friend.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement