Can't switch from fullscreen to windowed

I’m trying to use SDL as the basis for a multiplatform game…My development
platform (and the primary target) is Windows/DirectX.

I’m currently running Windows 2000, DirectX 7, on a GeForce 2. Visual C++
6.0, SP4…

The game I am writing has to be able to be switched from fullscreen to
windowed and back again (ala Quake, etc). I’ve read that
SDL_WM_ToggleFullScreen doesn’t work under Windows, and my own tests seem to
prove this… I’ve also read that you can do the switch by calling
SDL_SetVideoMode again… With this method I have only had partial success.

Basically, what it boils down to is that if I start out in a windowed mode,
I can call SDL_SetVideoMode again with updated videoflags and wind up with a
working fullscreen view… When I call it – asking for a windowed mode –
from fullscreen mode, I get a a NULL (0x00) return from SDL_SetVideoMode.
This happens whether I start out in fullscreen (first toggle bombs out) or
start in windowed (first toggle works, when trying to go back to windowed it
bombs out).

The SDL_Error I get when this occurs is: DDraw created surface with wrong
pitch.

Does anyone have an easy answer as to what I might do to work around this?
Has anyone running Win2k/DX7 gotten an app to successfully switch from
fullscreen to windowed mode? I’m going to start trudging through the SDL
code, but I figured i’d ask here in case anyone has run into this before and
can offer some assistance…

Also, I’m under a bit of time pressure from the higherups. If I can’t get
SDL to reliably do this mode switching in the next couple of days I’m likely
going to be forced to scrap SDL use all together and program directly to
DirectX (throwing out portability, which was more my idea than the higher
ups, who dont really care much about non-Windows platforms).

Perhap’s it is a very bad solution…
But personnaly, I use this very very bad way to switch beetween fullsceen and
windowed mode.
I simply close the Video subsystem, reopen it, and call the setVideMode
function with the correct flags…

But if there is a better way, tell me it please.–
C’est ainsi que s’ach?ve ce mail… Et en vous laissant ? vos
m?ditations profondes, je vous salue bien bas.

from : @J.C

I’m trying to use SDL as the basis for a multiplatform game…My development
platform (and the primary target) is Windows/DirectX.

I’m currently running Windows 2000, DirectX 7, on a GeForce 2. Visual C++
6.0, SP4…

The game I am writing has to be able to be switched from fullscreen to
windowed and back again (ala Quake, etc). I’ve read that
SDL_WM_ToggleFullScreen doesn’t work under Windows, and my own tests seem to
prove this… I’ve also read that you can do the switch by calling
SDL_SetVideoMode again… With this method I have only had partial success.

Basically, what it boils down to is that if I start out in a windowed mode,
I can call SDL_SetVideoMode again with updated videoflags and wind up with a
working fullscreen view… When I call it – asking for a windowed mode –
from fullscreen mode, I get a a NULL (0x00) return from SDL_SetVideoMode.
This happens whether I start out in fullscreen (first toggle bombs out) or
start in windowed (first toggle works, when trying to go back to windowed it
bombs out).

The SDL_Error I get when this occurs is: DDraw created surface with wrong
pitch.

Does anyone have an easy answer as to what I might do to work around this?
Has anyone running Win2k/DX7 gotten an app to successfully switch from
fullscreen to windowed mode? I’m going to start trudging through the SDL
code, but I figured i’d ask here in case anyone has run into this before and
can offer some assistance…

Try making sure the width is divisible by 4. This is a bug/limitation of
SDL that will be fixed in future versions.

See ya,
-Sam Lantinga, Lead Programmer, Loki Entertainment Software