[SDL] Using IMG_Load with SDL_DisplayFormat
Altay Cebe
altaycebe at vpw.wh.uni-dortmund.de
Wed Oct 30 15:28:01 PST 2002
No, wait...it still doesn't work the way i want :-((
This works:
SDL_Surface * temp=IMG_Load ( "data/images/block.jpg");
if(temp){
blah=SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
}
else
{
//handle the error.
cout << "ERROR " << endl;
exit(1);
}
But I would like to store all SDL_Surfaces in a array
SDL_Surface ** pSurface_Array = new SDL_Surface[ objectCount ];
But when i try
pSurface_Array[i] = NULL;
SDL_Surface * temp= IMG_Load ( imageName );
SDL_Surface * blah = NULL;
if(temp){
blah=SDL_DisplayFormat(temp);
pSurface_Array[i]= blah;
SDL_FreeSurface(temp);
SDL_FreeSurface(blah);
}
else
{
//handle the error.
cout << "ERROR " << endl;
exit(1);
}
it still Segfaults. It doesn't work for that pSurface_Array . I experimented a
bit, but i can't keep it from seg faulting. It seems that temp is != NULL
because it doesn't even print "ERROR".
More information about the SDL
mailing list