浏览代码

Merge pull request #1037 from Lopuska/patch-9

Black screen fix
Areloch 10 年之前
父节点
当前提交
6a418d4d7f
共有 1 个文件被更改,包括 8 次插入5 次删除
  1. 8 5
      Engine/source/windowManager/win32/win32Window.cpp

+ 8 - 5
Engine/source/windowManager/win32/win32Window.cpp

@@ -149,7 +149,6 @@ const GFXVideoMode & Win32Window::getVideoMode()
 void Win32Window::setVideoMode( const GFXVideoMode &mode )
 {
    bool needCurtain = (mVideoMode.fullScreen != mode.fullScreen);
-   static bool first_load = true;
 
    if(needCurtain)
    {
@@ -219,12 +218,16 @@ void Win32Window::setVideoMode( const GFXVideoMode &mode )
 	}
 	else
 	{
-	   if (!first_load)
-		  ChangeDisplaySettings(NULL, 0);
+	   DISPLAY_DEVICE dd = GetPrimaryDevice();
+	   DEVMODE dv;
+	   ZeroMemory(&dv, sizeof(dv));
+	   dv.dmSize = sizeof(DEVMODE);
+           EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dv);
 
-	   first_load = false;
+	   if ((mode.resolution.x != dv.dmPelsWidth) || (mode.resolution.y != dv.dmPelsHeight))
+	       ChangeDisplaySettings(NULL, 0);
 
-       // Reset device *first*, so that when we call setSize() and let it
+           // Reset device *first*, so that when we call setSize() and let it
 	   // access the monitor settings, it won't end up with our fullscreen
 	   // geometry that is just about to change.