SFML community forums

Help => Graphics => Topic started by: retep998 on December 20, 2009, 11:49:53 pm

Title: Alpha channel when loading a sprite
Post by: retep998 on December 20, 2009, 11:49:53 pm
I'm trying to load a png image with an alpha channel yet the alpha channel doesn't seem to load. It just shows a black background.
Here's the relevent code.
Code: [Select]
sf::Image charSprite;
charSprite.LoadFromFile("gorgon_idle_1.png");


Code: [Select]
charSprite.Bind();
glBegin(GL_QUADS);
glColor3ub(255,255,255);
glTexCoord2s(0,0);
glVertex2d(blah->x-35,blah->y-90);
glTexCoord2s(1,0);
glVertex2d(blah->x+36,blah->y-90);
glTexCoord2s(1,1);
glVertex2d(blah->x+36,blah->y);
glTexCoord2s(0,1);
glVertex2d(blah->x-35,blah->y);
glEnd();
glBindTexture(GL_TEXTURE_2D,NULL);


The image loads and draws fine but it doesn't have an alpha channel loaded for some reason...[/code]
Title: Alpha channel when loading a sprite
Post by: Laurent on December 20, 2009, 11:57:58 pm
You have to enable and setup alpha-blending, it's disabled by default in OpenGL ;)
Title: Alpha channel when loading a sprite
Post by: retep998 on December 21, 2009, 12:03:38 am
Silly me, what a foolish mistake.
I added some code and everything works perfectly now.
Thanks for the friendly and fast help.