[SDL] Fwd: Re: Segmentation fault in SDL_DisplayFormat{,Alpha}

charly charlyghislain at gmail.com
Mon Sep 17 05:31:05 PDT 2007


My fault. I moved the object creation before calling SDL_Init(). 

But thanks for pointing me changes needed in this function.

Charly


On Friday 14 September 2007 13:13:43 you wrote:
> Hi,
>
> I'm starting playing around with SDL. Im using Lazy FOo'
> tutorials(http://lazyfoo.net/SDL_tutorials/index.php) to help me.
>
> The prog here used to work, i don't know what i did to make it crash now.
> No changes were made in the crashing functions.
> gdb reports:
> #0  0xb7f0d0e3 in SDL_DisplayFormatAlpha () from /usr/lib/libSDL-1.2.so.0
> #1  0x08049a74 in load_image (filename=@0xbfe0eb08) at wrappers.cpp:18
> #2  0x08049495 in Plane (this=0xbfe0eb44, planeid=0, planetype=0)
>     at plane.cpp:22
> #3  0x08049ccc in main () at abricots.cpp:46
>
> And here's my load_image function:
>
> SDL_Surface *load_image(std::string filename)
> {
>     SDL_Surface *loadedImage = NULL;
>     SDL_Surface *optimizedImage = NULL;
>     loadedImage = IMG_Load( filename.c_str() );
>     if( loadedImage != NULL )
>     {
>         std::cout << "Image loaded!\n";
>         Uint32 colorkey = SDL_MapRGB( loadedImage->format, 0xFF, 0, 0xFF );
>         optimizedImage = SDL_DisplayFormatAlpha( loadedImage );
>         SDL_FreeSurface( loadedImage );
>     }
>     return optimizedImage;
> }
>
> The image being loaded is a simple 24 bits png wich, as i said, loaded fine
> before. SDL_SetVideoMode is called as SDL_SetVideoMode( 800, 600, 24,
> SDL_HWSURFACE );
>
> The last changes made inclued a timer to move the surface smoothly
> regardless of the framerate. Let me know if you want me to join the whole
> prog (7 files).
>
> Regards,


More information about the SDL mailing list