[SOURCE]
void gmp_splashscreenrun(SDL_Surface *splashtemp)
{
SplashScreen.setGraphic(splashtemp);
SplashScreen.setX((SCR_W/2)-(SplashScreen.getGraphicWidth()/2));
SplashScreen.setY((SCR_H/2)-(SplashScreen.getGraphicHeight()/2));
for(int i = 0;i<255;i++)
{
SDL_FillRect( gfx_screen, &gfx_screen->clip_rect, SDL_MapRGB( gfx_screen->format, 0xFF, 0xFF, 0xFF ) );
SDL_SetAlpha(SplashScreen.graphic, SDL_SRCALPHA, i);
SDL_Delay(10);
if (i == 254)
{SDL_Delay(25);}
SplashScreen.draw();
gfx_flipscreen();
}
for(int i = 255;i>0;i--)
{
SDL_FillRect( gfx_screen, &gfx_screen->clip_rect, SDL_MapRGB( gfx_screen->format, 0xFF, 0xFF, 0xFF ) );
SDL_SetAlpha(SplashScreen.graphic, SDL_SRCALPHA, i);
SDL_Delay(10);
if (i == 1)
{SDL_Delay(25);}
SplashScreen.draw();
gfx_flipscreen();
}
SDL_FreeSurface(SplashScreen.graphic);
}
[/SOURCE]
Can someone check this SDL code?
Can anyone tell me if this code is wrong?
[/source]
as far as I know there is not a problem with it, it compliles ok, but it crashes whenever it tries to Free the Surface
I can't see anything wrong that would cause a crash. Check that you aren't freeing the surface again in the SplashScreen destructor.
Good Luck.
Good Luck.
is the destructor being called though? Ill check to see if the destructor is removing the SDL surface.
other than that, the code looks good?
thanks again
ok,
I checked and I dont have the destructor calling the SDL_FreeSurface.
but I thought about it, would it be better to call have it? how does this code look?
with the destructor
oh yeah the game still crashes whenever it completes the function. i dont understand why! its when i call the SDL_FreeSurface....
[Edited by - psiko_scweek on October 9, 2006 10:49:18 PM]
other than that, the code looks good?
thanks again
ok,
I checked and I dont have the destructor calling the SDL_FreeSurface.
but I thought about it, would it be better to call have it? how does this code look?
void gmp_splashscreenrun(SDL_Surface *splashtemp){Object SplashScreen;SplashScreen.setGraphic(splashtemp);SplashScreen.setX((SCR_W/2)-(SplashScreen.getGraphicWidth()/2));SplashScreen.setY((SCR_H/2)-(SplashScreen.getGraphicHeight()/2));for(int i = 0;i<255;i++) { SDL_FillRect( gfx_screen, &gfx_screen->clip_rect, SDL_MapRGB( gfx_screen->format, 0xFF, 0xFF, 0xFF ) ); SDL_SetAlpha(SplashScreen.graphic, SDL_SRCALPHA, i); SDL_Delay(10); if (i == 254) {SDL_Delay(25);} SplashScreen.draw(); gfx_flipscreen(); }for(int i = 255;i>0;i--) { SDL_FillRect( gfx_screen, &gfx_screen->clip_rect, SDL_MapRGB( gfx_screen->format, 0xFF, 0xFF, 0xFF ) ); SDL_SetAlpha(SplashScreen.graphic, SDL_SRCALPHA, i); SDL_Delay(10); if (i == 1) {SDL_Delay(25);} SplashScreen.draw(); gfx_flipscreen(); }}
with the destructor
/////////// SETUP THE OBJECTS DESTRUCTOR ///////////Object::~Object(){if (graphic != NULL) {SDL_FreeSurface(graphic);}}
oh yeah the game still crashes whenever it completes the function. i dont understand why! its when i call the SDL_FreeSurface....
[Edited by - psiko_scweek on October 9, 2006 10:49:18 PM]
Try running SDL in software mode and see if that gets rid if your troubles. Do this by passing SDL_SWSURFACE to SDL_SetVideoMode in place of SDL_HWSURFACE and SDL_DOUBLEBUF.
I have had this exact problem before when using hardware surfaces.
I have had this exact problem before when using hardware surfaces.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement