Resize screen under MacOS x (crash)

Thanks to Christian for the help :stuck_out_tongue:
Hi People!
I tried to change the screen resolution in my application (compiled
under MacOS X), and … it crashes!
Well, I’m still a newbie, but the guilty code is that :
[…]
int CSubsystem::InitScreen (bool FullScreen) {
Uint32 Flags;
if (Initialized && !Locked) {
Flags = (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL);
if (FullScreen) Flags |= SDL_FULLSCREEN;
else Flags |= SDL_RESIZABLE;
if (Screen) { SDL_FreeSurface(Screen); Screen = NULL; }
if (!(Screen = SDL_SetVideoMode(ResX, ResY, Bpp, Flags)) return 1;
} else return 1;
return 0;
}
[…]
int CSubsystem::ResizeScreen (unsigned int ResX, unsigned int ResY,
unsigned int Bpp, bool FullScreen) {
if (Initialized && !Locked) {
this->ResX = ResX;
this->ResY = ResY;
this->Bpp = Bpp;
if (InitScreen(FullScreen) > 0) return 1;
} else return 1;
return 0;
}
[…]
if (Screen.InitScreen(false) > 0) return 1;
if (Screen.GetSizeX() < 1024) if (Screen.ResizeScreen(1024, 768, 32,
false) > 0) return 1;
When changing resolution, the window frame changes its size but
doesn’t show any content and the program freezes.
Any ideas ?
Bye, and Thanks again for your patience :stuck_out_tongue:

Andrea ‘Psycho’ Nardinocchi wrote:

I tried to change the screen resolution in my application (compiled
under MacOS X), and … it crashes!

I can still see some problems with your code, at first glance, though I
think they shouldn’t be causing crashes. Can you run the application in
a debugger to see where it crashes exactly? Or maybe provide a complete
test case so that we can test it ourselves?

Flags = (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL);

SDL_HWACCEL is not a flag that you pass to SDL_SetVideoMode. Read the
documentation again.

if (Screen) { SDL_FreeSurface(Screen); Screen = NULL; }

Don’t free the display surface, SDL handles that on its own.

Thanks to Christian for the help :stuck_out_tongue:

(You’re welcome, but I can’t help wondering whether you really think
that people are more likely to help you if you stick out your tongue at
them… :wink: )

-Christian