Segmentation Fault <SDL parachute deployed> *crash*

Hi, first post here :wink:

I was wondering if anyone knows why on Earth this is happening. Here’s
the code. It crashes after “something be wrong with…” - so the
bitmap isn’t loading correctly or not at all, since DisplayFormat
thinks it’s being given a NULL pointer? Any ideas on why the bitmap
wouldn’t load properly - it’s a 100x75pxl 24bit bitmap drawn in MS
Paint… I’m new to SDL and quite eager to get on with something but
I’ve no idea what’s happening here (been trying to figure it out for a
few days too :P) Thanks for any ideas.

SDL_Surface * loadBitmap(char *file)
{
SDL_Surface *temp1, *temp2; cout << “temp surfaces created\n”;
//temp1 = SDL_LoadBMP(file); cout << “bitmap loaded in\n”;
if((temp1 = SDL_LoadBMP(file)) == NULL)
{
cout << “something be wrong with that thar bitmap”;
}
temp2 = SDL_DisplayFormat(temp1); cout << “Display format set\n”;
SDL_FreeSurface(temp1); cout << “temp1 freed\n”;
return temp2; cout << “temp2 returning\n”;
}

Did you init the Screen before callin’ this function ?
If you didn’t SDL_DisplayFormat dowsn’t know to whot format convert
your Image

Losky

El mar, 24-02-2004 a las 14:28, coles_sam_wargaming escribi?:> Hi, first post here :wink:

I was wondering if anyone knows why on Earth this is happening. Here’s
the code. It crashes after “something be wrong with…” - so the
bitmap isn’t loading correctly or not at all, since DisplayFormat
thinks it’s being given a NULL pointer? Any ideas on why the bitmap
wouldn’t load properly - it’s a 100x75pxl 24bit bitmap drawn in MS
Paint… I’m new to SDL and quite eager to get on with something but
I’ve no idea what’s happening here (been trying to figure it out for a
few days too :P) Thanks for any ideas.

SDL_Surface * loadBitmap(char *file)
{
SDL_Surface *temp1, *temp2; cout << “temp surfaces created\n”;
//temp1 = SDL_LoadBMP(file); cout << “bitmap loaded in\n”;
if((temp1 = SDL_LoadBMP(file)) == NULL)
{
cout << “something be wrong with that thar bitmap”;
}
temp2 = SDL_DisplayFormat(temp1); cout << “Display format set\n”;
SDL_FreeSurface(temp1); cout << “temp1 freed\n”;
return temp2; cout << “temp2 returning\n”;
}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl