Sign in to follow this  

SDL_DisplayFormat() does NOT receive NULL?

This topic is 3599 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3599 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this