Win32 - Fix crash on failure to toggle to fullscreen.

This commit is contained in:
mart0258 2009-12-19 23:58:38 +00:00
parent 03bb053a7f
commit 2a57a4287a
2 changed files with 10 additions and 3 deletions

View File

@ -234,6 +234,7 @@ int SetVideoMode(int fs)
PaletteChanged=1;
ResetVideo();
fullscreen=fs;
if(!InitializeDDraw(fs)) return(1); // DirectDraw not initialized
@ -410,6 +411,7 @@ int SetVideoMode(int fs)
ShowDDErr("Error getting attached surface.");
return 0;
}
// FIXME: The back buffer isn't cleared properly, causing massive flickering.
}
if(!GetBPP())
@ -479,6 +481,8 @@ static void BlitScreenWindow(unsigned char *XBuf)
RECT drect;
int specialmul;
if (!lpDDSBack) return;
if(winspecial == 2 || winspecial == 1)
specialmul = 2;
else if(winspecial == 4 || winspecial == 3)
@ -547,12 +551,13 @@ static void BlitScreenFull(uint8 *XBuf)
else
specmul = 1;
if(fssync==3)
lpDDSVPrimary=lpDDSDBack;
else
lpDDSVPrimary=lpDDSPrimary;
if (!lpDDSVPrimary) return;
if(PaletteChanged==1)
{
if(bpp>=16)

View File

@ -975,8 +975,10 @@ static void ToggleFullscreen(void)
UpdateCheckedMenuItems();
changerecursive=1;
if(!SetVideoMode(fullscreen^1))
SetVideoMode(fullscreen);
int oldmode = fullscreen;
if(!SetVideoMode(oldmode ^1))
SetVideoMode(oldmode);
changerecursive=0;
#endif
}