Hey, so I've been trying to implement the SDL library, but I've run into a problem: SDL_DisplayFormat() isn't working! I stepped through my code, and the image seems to be loaded into temp, but when it gets passed to SDL_DisplayFormat, the function returns NULL. Any idea why this is? Or is there a way to further debug? It seemed to be working earlier, but I can't figure out what broke it.
temp and surface.sourceImg are SDL_Surface*.
How big is the image you're trying to load? I've had a similar problem before and I believe I may have been trying to load too big of an image (750x650 or something like that).
Also, did you initiate the image format you're using for SDL_image?
SDL_DisplayFormat works by converting the target surface to a surface compatible with the current display. So, you cannot call it before you have called SDL_SetVideoMode. Load your image after that call, and everything should work fine.
Also, use SDL_DisplayFormatAlpha on images loaded using IMG_Load.
TheBuzzSaw wrote:SDL_DisplayFormat works by converting the target surface to a surface compatible with the current display. So, you cannot call it before you have called SDL_SetVideoMode. Load your image after that call, and everything should work fine.
Also, use SDL_DisplayFormatAlpha on images loaded using IMG_Load.
Sweet! That fixed it. And I assume you meant I should replace SDL_DisplayFormat instead of IMG_Load?
Also, while the program appears to compile successfully, I get a lot of messages like:
'MonkeyLabs.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'MonkeyLabs.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
Any idea why this is happening?
No. I am saying that if you use IMG_Load, you should use SDL_DisplayFormatAlpha instead of SDL_DisplayFormat. Since IMG_Load can load transparent formats (GIF/PNG), using SDL_DisplayFormatAlpha will properly enable those transparencies. On non-transparent formats, it'll work fine too, so it's good to just be consistent.