EDIT: I have figured out that it is SDL_DisplayFormat that is causing the issue. Now to just figure out what to do about it.....
EDIT 2: SDL_DisplayFormatAlpha fixed the issue. It carries over the alpha value of the image, hence making it transparent. I am not sure whether I should delete this post since it is solved,or if maybe I should leave it up for another beginner who has the same issue? maybe a moderator can help me out.
I am following this tutorial: http://www.sdltutorials.com/sdl-coordinates-and-blitting. The only difference is I am using the SDL_Image extension to SDL so I can load in .png files. I have used the exact code as the author of the tutorial, except I use IMG_Load("whatever file") instead of SDL_LoadBMP so that I can have transparent images. The images however are not transparent when I blit them to the screen. Yes, they actual images files themself are transparent.One problem I thought might be the issue is that I am using SDL_BlitSurface. I'm not sure if there is another function I need to use with IMG_Load to make the images transparent, but I don't believe so. Below I have the code I am using. If someone could help me out I'd really appreciate it!. Thanks!!
The code below is the function that loads in my image. I thought maybe SDL_DisplayFormat might be the problem, but I have not found anything info on Google agreeing with this.
SDL_Surface* CSurface::OnLoad(char* File){
SDL_Surface* Surf_Temp = NULL;//The variable that temporarily stores the image when it is loaded in
SDL_Surface* Surf_Return = NULL;//The variable where the modified image from Surf_Temp will be stored
//Loads an image in or returns NULL if no image is loaded
if ((Surf_Temp = IMG_Load(File)) == NULL){
return NULL;
}
Surf_Return = SDL_DisplayFormat(Surf_Temp);//Formats the image in Surf_Return to match the display
SDL_FreeSurface(Surf_Temp);//Frees the temporary variable Surf_Temp from memory since it is no longer needed
return Surf_Return;//The function returns the image in Surf_Return
}
bool CSurface::OnDraw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, int X, int Y){
if (Surf_Dest == NULL || Surf_Src == NULL){
return false;
}
SDL_Rect DestR;
DestR.x = X;
DestR.y = Y;
SDL_BlitSurface(Surf_Src, NULL, Surf_Dest, &DestR);
return true;
}