SDL_DisplayFormat() does NOT receive NULL?

Started by
3 comments, last by Jesse Chung 16 years, 2 months ago
I wrote somthing and always got "core dumped". After debuging, I think it was SDL_DisplayFormat(). Some testing code shows that, if it gets a NULL, the program will crash.(A video mode have firstly been set) . I am not quite sure. Could somebody kindly give me a hand?
Advertisement
You can start here.

http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fDisplayFormat

I'm not quite sure what you mean by "if it gets a NULL." To get any sort of meaningful answer, you're going to have to post some code that shows the bug.
if( !(loaded = SDL_LoadBMP("background.bmp")) )
return 1;
optimized = SDL_DisplayFormat(loaded);

If the code went like above, everything is ok. But if I remove the check with 'if(!)', it crashes.
I mean, since SDL_DisplayFormat get a parameter of (SDL_Surface *surface), I want to figure out if this parameter can be NULL.
No, the parameter cannot be NULL. SDL_LoadBMP is returning NULL, it's failing to load the BMP file.
Yeah I got it. I just thought I could pass a NULL argument and SDL_DisplayFormat could deal with that( e.g. returning NULL as well )... Then I do not have to check the results of both SDL_LoadBMP and SDL_DisplayFormat.
If the parameter cannot be NULL, now I have to make sure SDL_LoadBMP loads the image well and SDL_DisplayFormat transfers it well.
Thank you a lot.

This topic is closed to new replies.

Advertisement