I am beginning programming in SDL 2.0. I would like to be able to load .PNG files into my program, as .bmp files don't have all the neat features .png files do.
I have the following code from http://www.sdltutorials.com/sdl-image:
SDL_Surface* loadSurf(char* File) {
SDL_Surface* Surf_Temp = NULL;
SDL_Surface* Surf_Return = NULL;
if((Surf_Temp = IMG_Load(File)) == NULL) {
return NULL;
}
Surf_Return = SDL_DisplayFormatAlpha(Surf_Temp);
SDL_FreeSurface(Surf_Temp);
return Surf_Return;
}
The point of the function is to load an image, you would go about calling it by doing something like:
SDL_Surface* character = loadSurf("sprite.png");
However, when I run it, an error appears at the "Surf_Return = SDL_DisplayFormatAlpha(Surf_Temp); " line. The error is: Use of undeclared identifier 'SDL_DisplayFormatAlpha'
I figure that the reason for this is because the code was written for SDL 1.2, and I am using SDL 2.0. Is there a way to convert this function into SDL 2.0?
I am running Mac OSX 10.13.2, if that is applicable.