Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Alpha channel when loading a sprite  (Read 2127 times)

0 Members and 1 Guest are viewing this topic.

retep998

  • Newbie
  • *
  • Posts: 17
    • View Profile
Alpha channel when loading a sprite
« 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]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Alpha channel when loading a sprite
« Reply #1 on: December 20, 2009, 11:57:58 pm »
You have to enable and setup alpha-blending, it's disabled by default in OpenGL ;)
Laurent Gomila - SFML developer

retep998

  • Newbie
  • *
  • Posts: 17
    • View Profile
Alpha channel when loading a sprite
« Reply #2 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.

 

anything