PATCH: D3D8 resolution changing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings all,
This is a small patch to let D3D8 applications change the resolution. If my previous patch is applied, then it works for Wine-desktop-mode as well by resizing the desktop window.


The key here was the reordering of those two header lines at the top of this file. Without that, ChangeDisplaySettings got implicitly defined which led to a crash.

-ajp


ChangeLog: - Enable resolution changes for D3D8 applications

Index: dlls/d3d8/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/directx.c,v
retrieving revision 1.49
diff -u -r1.49 directx.c
--- dlls/d3d8/directx.c	5 Sep 2003 23:08:41 -0000	1.49
+++ dlls/d3d8/directx.c	15 Sep 2003 16:25:31 -0000
@@ -26,8 +26,8 @@
 #define NONAMELESSSTRUCT
 #include "windef.h"
 #include "winbase.h"
-#include "winuser.h"
 #include "wingdi.h"
+#include "winuser.h"
 #include "wine/debug.h"
 #include "wine/unicode.h"
 
@@ -44,39 +44,6 @@
     X11DRV_GET_FONT,      /* get current X font for a DC */
 };
 
-#define NUM_MODES 20
-static const int modes[NUM_MODES][4] = {
-    {640, 480, 85, 16},
-    {640, 480, 85, 32},
-
-    {800, 600, 85, 16},
-    {800, 600, 85, 32},
-
-    {1024, 768, 85, 16},
-    {1024, 768, 85, 32},
-
-    {1152, 864, 85, 16},
-    {1152, 864, 85, 32},
-
-    {1280, 768, 85, 16},
-    {1280, 768, 85, 32},
-
-    {1280, 960, 85, 16},
-    {1280, 960, 85, 32},
-
-    {1280, 1024, 85, 16},
-    {1280, 1024, 85, 32},
-
-    {1600, 900, 85, 16},
-    {1600, 900, 85, 32},
-
-    {1600, 1024, 85, 16},
-    {1600, 1024, 85, 32},
-
-    {1600, 1200, 85, 16},
-    {1600, 1200, 85, 32}
-};
-
 #define NUM_FORMATS 7
 static const D3DFORMAT device_formats[NUM_FORMATS] = {
   D3DFMT_P8,
@@ -189,18 +156,14 @@
     }
 
     if (Adapter == 0) { /* Display */
-        int maxWidth        = GetSystemMetrics(SM_CXSCREEN);
-        int maxHeight       = GetSystemMetrics(SM_CYSCREEN);
-        int i;
-
-        for (i = 0; i < NUM_MODES; i++) {
-            if (modes[i][0] > maxWidth || modes[i][1] > maxHeight) {
-  	        TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, i + 1);
-                return i + 1;
-            }
+        DEVMODEW DevModeW;
+        int i = 0;
+
+        while (EnumDisplaySettingsExW(NULL, i, &DevModeW, 0)) {
+            TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, i);
+            i++;
         }
-	TRACE("(%p}->(Adapter: %d) => %d\n", This, Adapter, NUM_MODES);
-        return NUM_MODES + 1;
+        return i;
     } else {
         FIXME("Adapter not primary display\n");
     }
@@ -221,18 +184,17 @@
     if (Adapter == 0) { /* Display */
         HDC hdc;
         int bpp = 0;
+        DEVMODEW DevModeW;
 
-        if (Mode == 0) {
-            pMode->Width        = GetSystemMetrics(SM_CXSCREEN);
-            pMode->Height       = GetSystemMetrics(SM_CYSCREEN);
-            pMode->RefreshRate  = 85; /*FIXME: How to identify? */
-	    bpp                 = 32;
-        } else if (Mode < (NUM_MODES + 1)) {
-            pMode->Width        = modes[Mode - 1][0];
-            pMode->Height       = modes[Mode - 1][1];
-            pMode->RefreshRate  = modes[Mode - 1][2];
-	    bpp                 = modes[Mode - 1][3];
-        } else {
+        if (EnumDisplaySettingsExW(NULL, Mode, &DevModeW, 0)) 
+        {
+            pMode->Width        = DevModeW.dmPelsWidth;
+            pMode->Height       = DevModeW.dmPelsHeight;
+            pMode->RefreshRate  = D3DADAPTER_DEFAULT;
+	    bpp                 = DevModeW.dmBitsPerPel;
+        }
+        else
+        {
             TRACE("Requested mode out of range %d\n", Mode);
             return D3DERR_INVALIDCALL;
         }
@@ -1044,7 +1006,7 @@
     /* If not windowed, need to go fullscreen, and resize the HWND to the appropriate  */
     /*        dimensions                                                               */
     if (!pPresentationParameters->Windowed) {
-#if 0
+#if 1
 	DEVMODEW devmode;
 	HDC hdc;
         int bpp = 0;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux