SDL_SetVideoMode problem

Hi,

I’m using SDL in software mode for our upcoming game
Gemsweeper (http://lobstersoft.com/gemsweeper). The game
usually runs fullscreen at 1024*768, 32bpp.

Usually it works fine, but there is at least one beta tester
who has reported frequent screen resolution switching
problems when playing Gemsweeper in full- screen mode. The
screen is shifted to one side in a cyclic manner. The game
runs fine, but looks very strange.

When he restarts the game it usually works the second time.

He sent me three screenshots, which I have uploaded here.



This is the source code I am using for creating the main
blit surface and switching screen resolution:

Uint32 flags = SDL_SWSURFACE; if (FullScreen) {
flags|=SDL_FULLSCREEN; }

putenv((“SDL_VIDEO_WINDOW_POS=”+IntToStr(max(0,(g_GameBase.G
etWindowsDesktopDime nsions().GetWidth()-
GetWidth())/2))+","+IntToStr(max(0,((g_GameBase.GetWindowsDe
sktopDimensions().Ge tHeight()-GetHeight())/2)-
8))).c_str()); //switch screen resolution. We are using
software mode only.
VideoSurface=SDL_SetVideoMode(1024,768,32,flags);

My first thought was that it might be an old, faulty CRT
screen, but the user told me he is using a 3-year old 19"
Flatscreen. He also insisted that this problem does not
happen when he is using other games or applications.

I’m really at a loss on how to proceed here. Any suggestions
would be greatly
appreciated.

putenv((“SDL_VIDEO_WINDOW_POS=”

In general, don’t use SDL_VIDEO_WINDOW_POS, and never, never use it for
fullscreen video modes.

–ryan.

Ryan C. Gordon <icculus icculus.org> writes:

putenv((“SDL_VIDEO_WINDOW_POS=”

In general, don’t use SDL_VIDEO_WINDOW_POS, and never, never use it for
fullscreen video modes.

–ryan.

Thanks for the suggestion, I will try that.

Is there any other way to make sure that the window (when playing in windowed
mode) ist nicely set to the middle of the screen?

– Adrian

This will work well:
SDL_putenv(“SDL_VIDEO_CENTERED=1”);

However, it will only work for the first window that is initialized. I mean
that if you start with a splash screen which is say at 100x100, and then
after loading all your stuff, you change the window size to 450x450, the
upper left corner will remain in the same spot. REALLY annoying.

This can be resolved by having the SDL_VIDEO_CENTERED = 1 as a global
environmental variable (set in the OS’s global env var’s), but that’s a
stretch to ask the end-user to do such a thing.

I find that even if I call SDL_putenv(“SDL_VIDEO_CENTERED=1”) again before
making the 2nd window, it still behaves in the annoying manner of not
actually being centered.

If all you do is use one window size throughout, though, you’re set!
Hope this helps!
-Dave Olsen> ----- Original Message -----

From: adrian@lobstersoft.com (Adrian Grigore)
To:
Sent: Sunday, February 04, 2007 1:48 PM
Subject: Re: [SDL] SDL_SetVideoMode problem

Ryan C. Gordon <icculus icculus.org> writes:

putenv((“SDL_VIDEO_WINDOW_POS=”

In general, don’t use SDL_VIDEO_WINDOW_POS, and never, never use it for
fullscreen video modes.

–ryan.

Thanks for the suggestion, I will try that.

Is there any other way to make sure that the window (when playing in
windowed
mode) ist nicely set to the middle of the screen?

– Adrian


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

David Olsen <jolynsbass gmail.com> writes:

This will work well:
SDL_putenv(“SDL_VIDEO_CENTERED=1”);

If all you do is use one window size throughout, though, you’re set!
Hope this helps!
-Dave Olsen

Thanks Dave, it certainly does help! :slight_smile:

Adrian