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