PDA

View Full Version : Leaving fullscreen mode in Windows



Srki_82
30-01-2007, 10:43 PM
My desktop resolution is 1280x1024. I use SDL_SetVideoMode with fullscreen flag to enter fullscreen mode (800x600) and that works fine. When I try to exit fullscreen mode (calling SDL_SetVideoMode without fullscreen flag) my desktop resolution isn't restored... it's still 800x600.

How can I exit fullscreen mode properly?

jdarling
31-01-2007, 12:51 AM
Try something like this (pulled straight from JumpStart so it should work)



var
videoFlags : UInt32;
videoInfo : PSDL_VideoInfo;

procedure InitRenderInfo;
begin
if SDL_Init&#40; SDL_INIT_VIDEO &#41; <> 0 then
halt;
InitSoundEngine;
CreateScriptEngine;
videoInfo &#58;= SDL_GetVideoInfo;
if videoInfo = nil then
halt;

videoFlags &#58;= videoFlags or SDL_DOUBLEBUF; // Enable double buffering
videoFlags &#58;= videoFlags or SDL_HWPALETTE; // Store the palette in hardware

// This checks to see if surfaces can be stored in memory
if &#40;videoInfo^.hw_available <> 0&#41; then
videoFlags &#58;= videoFlags or SDL_HWSURFACE
else
videoFlags &#58;= videoFlags or SDL_SWSURFACE;

// This checks if hardware blits can be done * /
if &#40;videoInfo^.blit_hw <> 0&#41; then
videoFlags &#58;= videoFlags or SDL_HWACCEL;
end;

procedure SetVideoMode&#40;Width, Height, BPP &#58; Integer; FullScreen &#58; Boolean&#41;;
begin
if FullScreen then
videoFlags &#58;= videoFlags or SDL_FULLSCREEN
else
videoFlags &#58;= videoFlags and &#40;not SDL_FULLSCREEN&#41;;
if Screen <> nil then
SDL_FreeSurface&#40; Screen &#41;;
Screen &#58;= SDL_SetVideoMode&#40; Width, Height, BPP, videoFlags &#41;;
end;

Srki_82
31-01-2007, 10:58 AM
Thanks... I was missing SDL_FreeSurface in my code.