Alpha Channels not working!

Started by
7 comments, last by Ezbez 17 years, 10 months ago
I've been trying to get transparency in my graphics for a few days now, and it's just not working. I am loading my pictures into my game through SDL and C++. I am using photoshop to make my graphics, and decided to use the alpha channels to get my transparency instead of using colorkeys. I've read numerous tutorials on how this is done but I still get a white background. Here are some pictures of what I'm talking about: 1)Program running: http://img528.imageshack.us/img528/5301/program6jb.png 2)Shows the layers in PS: http://img112.imageshack.us/img112/7412/layers8kx.png 3)Shows the channels and alpha layer: http://img112.imageshack.us/img112/9789/channels1mm.png
Advertisement
Quote:Original post by Sentralia
I've been trying to get transparency in my graphics for a few days now, and it's just not working. I am loading my pictures into my game through SDL and C++. I am using photoshop to make my graphics, and decided to use the alpha channels to get my transparency instead of using colorkeys. I've read numerous tutorials on how this is done but I still get a white background. Here are some pictures of what I'm talking about:

1)Program running: http://img528.imageshack.us/img528/5301/program6jb.png

2)Shows the layers in PS: http://img112.imageshack.us/img112/7412/layers8kx.png

3)Shows the channels and alpha layer: http://img112.imageshack.us/img112/9789/channels1mm.png

are you saving the image as 32 bit?
-------------------------Only a fool claims himself an expert
Yes, it's a 32bit TGA. I have CS2, so I assume that TGA problem is fixed.
Quote:Original post by Sentralia
Yes, it's a 32bit TGA. I have CS2, so I assume that TGA problem is fixed.

well, my only other suggestion is try it without using a transparency background since there is no reason for it anyway and may be interfering with the alpha channel.
other thing is that if you're programing your game yourself make sure your code is good, try a texture you know that works in it to see if it is your code.
-------------------------Only a fool claims himself an expert
I would say there's a problem with your code? The image looks alright.
-------------www.robg3d.com
Yeah, it's definitely in the code. I just loaded the image into flash, and the background was transparent. I'll post the code, which was taken from Lazy Foo's Blitting tutorial:

This is my load.cpp

#include "load.h"

SDL_Surface *load_image( std::string filename )
{
SDL_Surface* loadedImage = NULL;
SDL_Surface* optimizedImage = NULL;
loadedImage = IMG_Load( filename.c_str() );

if( loadedImage != NULL )
{
optimizedImage = SDL_DisplayFormat( loadedImage );
SDL_FreeSurface( loadedImage );
}



return optimizedImage;

}
void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_BlitSurface( source, NULL, destination, &offset );
}


In my main.cpp I have the BPP set to 32. Check lazyfooproductions.com and check the blitting tutorial, this is where i got the code from.
Isn't there some type of SDL alpha function to allow the alpha channels to be used?
Why dont you use png instead.
My blog about personal development for studying people - www.tricktolearn.com
SDL does not do alpha channel blending.

Use SDL_DisplayFormatAlpha(), not just SDL_DisplayFormat().

This topic is closed to new replies.

Advertisement