winecfg: Add tab for most Direct3D registry settings.

Stephen Chao stephen-wine at digitalnexus.org
Sat Jan 14 11:37:10 CST 2012


---
 programs/winecfg/Makefile.in |    3 +-
 programs/winecfg/direct3d.c  |  256 ++++++++++++++++++++++++++++++++++++++++++
 programs/winecfg/main.c      |   16 +++-
 programs/winecfg/resource.h  |    8 ++
 programs/winecfg/winecfg.h   |    1 +
 programs/winecfg/winecfg.rc  |   12 ++
 6 files changed, 294 insertions(+), 2 deletions(-)
 create mode 100644 programs/winecfg/direct3d.c

diff --git a/programs/winecfg/Makefile.in b/programs/winecfg/Makefile.in
index 0190854..1db9fec 100644
--- a/programs/winecfg/Makefile.in
+++ b/programs/winecfg/Makefile.in
@@ -13,7 +13,8 @@ C_SRCS = \
 	main.c \
 	theme.c \
 	winecfg.c \
-	x11drvdlg.c
+	x11drvdlg.c \
+	direct3d.c
 
 RC_SRCS = winecfg.rc
 PO_SRCS = winecfg.rc
diff --git a/programs/winecfg/direct3d.c b/programs/winecfg/direct3d.c
new file mode 100644
index 0000000..833999e
--- /dev/null
+++ b/programs/winecfg/direct3d.c
@@ -0,0 +1,256 @@
+#include "winecfg.h"
+#include "resource.h"
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
+
+struct d3doption {
+  char key[64];
+  char option1[64];
+  char option2[64];
+  char option3[64];
+  char option4[64];
+  char option5[64];
+  char tip[2048];
+} *d3doptions;
+
+static const int numd3dkeys = 9;
+
+static void init_d3doptions(void)
+{
+  d3doptions = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct d3doption) * numd3dkeys);
+  
+  /* "auto" will be added for all options */
+  /* registry options and defaults found in dlls/wined3d/wined3d_main.c */
+  /* TODO: VideoPciDeviceID and VideoPciVendorID, see note in on_selection_change() */
+  
+  strcpy(d3doptions[0].key, "VertexShaderMode");
+  strcpy(d3doptions[0].option1, "none");
+  strcpy(d3doptions[0].tip, "auto = hardware.");
+  
+  strcpy(d3doptions[1].key, "PixelShaderMode");
+  strcpy(d3doptions[1].option1, "enabled");
+  strcpy(d3doptions[1].option2, "disabled");
+  strcpy(d3doptions[1].tip, "auto = enabled = hardware.");
+  
+  strcpy(d3doptions[2].key, "UseGLSL");
+  strcpy(d3doptions[2].option1, "disabled");
+  strcpy(d3doptions[2].tip, "auto = enabled.  Needed for most modern games.  May have performance increase when disabled but might not run/render properly.");
+
+  strcpy(d3doptions[3].key, "OffscreenRenderingMode");
+  strcpy(d3doptions[3].option1, "backbuffer");
+  strcpy(d3doptions[3].option2, "fbo");
+  strcpy(d3doptions[3].tip, "auto = fbo.");
+
+  strcpy(d3doptions[4].key, "RenderTargetLockMode");
+  strcpy(d3doptions[4].option1, "readdraw");
+  strcpy(d3doptions[4].option2, "readtex");
+  strcpy(d3doptions[4].tip, "auto = readtex.  readdraw uses glReadPixels for reading, glDrawPixels for writing.  readtex reads with glReadPixels, writes by drawing a textured quad.");
+  
+  strcpy(d3doptions[5].key, "VideoMemorySize");
+  strcpy(d3doptions[5].option1, "0");
+  strcpy(d3doptions[5].option2, "512");
+  strcpy(d3doptions[5].option3, "1024");
+  strcpy(d3doptions[5].tip, "auto = 0 = autodetect.  Sets the amount of reported video memory (in megabytes).  The default is a simple auto-detection based on the card type guessed from OpenGL capabilities.");
+  
+  strcpy(d3doptions[6].key, "Multisampling");
+  strcpy(d3doptions[6].option1, "disabled");
+  strcpy(d3doptions[6].tip, "auto = enabled.");
+
+  strcpy(d3doptions[7].key, "StrictDrawOrdering");
+  strcpy(d3doptions[7].option1, "enabled");
+  strcpy(d3doptions[7].tip, "auto = disabled.  This option ensures any pending drawing operations are submitted to the driver, but at a significant performance cost.");
+  
+  strcpy(d3doptions[8].key, "AlwaysOffscreen");
+  strcpy(d3doptions[8].option1, "enabled");
+  strcpy(d3doptions[8].tip, "auto = disabled.  Use offscreen rendering for all render targets.  The main effect this has is avoiding the depth buffer copy between offscreen and onscreen targets, which introduces fallbacks in some drivers and exposes bugs in others.  There may be a performance hit depending on the specific driver.");
+}
+
+
+static void on_setoption(HWND dialog, WPARAM wParam)
+{
+  LVITEM item;
+  int selection;
+  char buffer[256];
+  int index = -1;
+
+  if(HIWORD(wParam) == CBN_SELENDOK)
+  {
+    selection = SendDlgItemMessage(dialog, IDC_D3DCOMBOVAL, CB_GETCURSEL, 0, 0);
+    SendDlgItemMessage(dialog, IDC_D3DCOMBOVAL, CB_GETLBTEXT, selection, (LPARAM) buffer);
+  }
+  else if(HIWORD(wParam) == CBN_EDITCHANGE)
+  {
+    SendDlgItemMessage(dialog, IDC_D3DCOMBOVAL, WM_GETTEXT, sizeof(buffer), (LPARAM) buffer);
+  }
+
+  index = (int)SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_GETITEMDATA, 0, 0);
+  WINE_TRACE("d3d index %d, setoption %s\n", index, buffer);
+  
+  set_reg_key(config_key, keypath("Direct3D\\"), d3doptions[index].key, buffer);
+  SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
+  
+  item.mask = LVIF_TEXT;
+  item.pszText = buffer;
+  item.cchTextMax = lstrlen(item.pszText);
+  item.iItem = index;
+  item.iSubItem = 1;
+
+  SendDlgItemMessage(dialog, IDC_D3DLIST, LVM_SETITEM, 0, (LPARAM) &item);
+}
+
+static void on_selection_change(HWND dialog, HWND listview, LPNMLISTVIEW nmlistview)
+{
+  LVITEM item;
+  struct d3doption *option;
+  
+  item.iItem = nmlistview->iItem;
+  item.iSubItem = 1;
+  item.mask = LVIF_PARAM | LVIF_TEXT;
+
+  
+  if (item.iItem == -1) return;
+  
+  SendMessage(listview, LVM_GETITEM, 0, (LPARAM) &item);
+
+  WINE_TRACE("item.iItem=%d\n", nmlistview->iItem);
+  
+  option = (struct d3doption*)nmlistview->lParam;
+  
+  SetWindowText(GetDlgItem(dialog, IDC_D3DKEY), option->key);
+  
+  SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_RESETCONTENT, 0, 0);
+  
+  if (option->option5[0]) SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_INSERTSTRING, 0, (LPARAM)option->option5);
+  if (option->option4[0]) SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_INSERTSTRING, 0, (LPARAM)option->option4);
+  if (option->option3[0]) SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_INSERTSTRING, 0, (LPARAM)option->option3);
+  if (option->option2[0]) SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_INSERTSTRING, 0, (LPARAM)option->option2);
+  if (option->option1[0]) SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_INSERTSTRING, 0, (LPARAM)option->option1);
+
+  /* Will have to take out "auto" for VideoPciDeviceID and VideoPciVendorID, 0xffff = autodetect */
+  SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_INSERTSTRING, 0, (LPARAM)"auto");
+  
+  SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_SELECTSTRING, -1, (LPARAM)item.pszText);
+  
+  /* attach d3d key index to the 0th combobox value */
+  SendDlgItemMessage (dialog, IDC_D3DCOMBOVAL, CB_SETITEMDATA, 0, (LPARAM)item.iItem);
+  
+  SetWindowText(GetDlgItem(dialog, IDC_D3DTIP), option->tip);
+}
+
+void load_d3d_registry(HWND dialog)
+{
+  LVITEM item, item2;
+  char *fromreg;
+  char szauto[] = "auto";
+  int i;
+  
+  SendDlgItemMessage(dialog, IDC_D3DLIST, LVM_DELETEALLITEMS, 0, 0);
+  
+  for (i=0; i < numd3dkeys; i++)
+  {
+    item.mask = LVIF_TEXT | LVIF_PARAM;
+    item.pszText = d3doptions[i].key;
+    item.cchTextMax = lstrlen(item.pszText);
+    item.lParam = (LPARAM) &d3doptions[i];
+    item.iItem = i;
+    item.iSubItem = 0;
+    
+    SendDlgItemMessage(dialog, IDC_D3DLIST, LVM_INSERTITEM, 0, (LPARAM) &item);
+    
+    fromreg = get_reg_key(config_key, keypath("Direct3D\\"), d3doptions[i].key, NULL);
+    if (fromreg == NULL)
+    {
+      /* set registry keys in case they didn't exist -- "auto" specifically */
+      set_reg_key(config_key, keypath("Direct3D\\"), d3doptions[i].key, szauto);
+      SendMessage(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
+      item2.pszText = szauto;
+    }
+    else
+    {
+      item2.pszText = fromreg;
+    }
+    
+    item2.mask = LVIF_TEXT;
+    item2.cchTextMax = lstrlen(item.pszText);
+    item2.iItem = i;
+    item2.iSubItem = 1;
+    
+    SendDlgItemMessage(dialog, IDC_D3DLIST, LVM_SETITEM, 0, (LPARAM) &item2);
+    
+    HeapFree(GetProcessHeap(), 0, fromreg);
+  }
+}
+
+static void init_d3dsheet(HWND dialog)
+{
+  char key[] = "Key";
+  char val[] = "Value";
+  
+  LVCOLUMN listColumn;
+  RECT viewRect;
+  int width;
+  
+  init_d3doptions();
+  
+  GetClientRect(GetDlgItem(dialog, IDC_D3DLIST), &viewRect);
+  width = (viewRect.right - viewRect.left);
+
+  listColumn.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
+  listColumn.pszText = key;
+  listColumn.cchTextMax = lstrlen (listColumn.pszText);
+  listColumn.cx = 140;
+
+  SendDlgItemMessage (dialog, IDC_D3DLIST, LVM_INSERTCOLUMN, 0, (LPARAM) &listColumn);
+
+  listColumn.cx = width - 140;
+  listColumn.pszText = val;
+  listColumn.cchTextMax = lstrlen (listColumn.pszText);
+
+  SendDlgItemMessage (dialog, IDC_D3DLIST, LVM_INSERTCOLUMN, 1, (LPARAM) &listColumn);
+}
+
+
+INT_PTR CALLBACK
+Direct3DDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+switch (uMsg)
+  {
+    case WM_INITDIALOG:
+        init_d3dsheet(hDlg);
+        break;
+
+    case WM_SHOWWINDOW:
+        set_window_title(hDlg);
+        break;
+
+    case WM_NOTIFY:
+      switch (((LPNMHDR)lParam)->code)
+      {
+        case LVN_ITEMCHANGED:
+            on_selection_change(hDlg, GetDlgItem(hDlg, IDC_D3DLIST), (LPNMLISTVIEW)lParam);
+            break;
+	case PSN_SETACTIVE:
+            load_d3d_registry(hDlg);
+            break;
+	case PSN_KILLACTIVE:
+            SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
+            break;
+        case PSN_APPLY:
+            apply();
+            SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
+            break;
+      }
+    case WM_COMMAND:
+      switch (HIWORD(wParam))
+      {
+        case CBN_EDITCHANGE:
+        case CBN_SELENDOK:
+             on_setoption(hDlg, wParam);
+             break;
+      }
+      
+      break;
+  }
+  return 0;
+}
diff --git a/programs/winecfg/main.c b/programs/winecfg/main.c
index 7376309..ccd59b0 100644
--- a/programs/winecfg/main.c
+++ b/programs/winecfg/main.c
@@ -60,7 +60,7 @@ PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
     return 0;
 }
 
-#define NUM_PROPERTY_PAGES 7
+#define NUM_PROPERTY_PAGES 8
 
 static INT_PTR
 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
@@ -84,6 +84,20 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
     pg++;
 
     /*
+     * Fill out the (Direct3D) PROPSHEETPAGE data structure
+     * for the property sheet
+     */
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
+    psp[pg].dwFlags = PSP_USETITLE;
+    psp[pg].hInstance = hInstance;
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_DIRECT3DCFG);
+    psp[pg].u2.pszIcon = NULL;
+    psp[pg].pfnDlgProc = Direct3DDlgProc;
+    psp[pg].pszTitle = load_string (IDS_TAB_DIRECT3D);
+    psp[pg].lParam = 0;
+    pg++;
+
+    /*
      * Fill out the (Libraries) PROPSHEETPAGE data structure 
      * for the property sheet
      */
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index 6d9c450..826b840 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -45,6 +45,7 @@
 #define IDS_SHELL_FOLDER                16
 #define IDS_LINKS_TO                    17
 #define IDS_WINECFG_TITLE_APP           18   /* App specific title */
+#define IDS_TAB_DIRECT3D                19
 #define IDI_WINECFG                     100
 #define IDD_MAINDLG                     101
 #define IDI_LOGO                        102
@@ -54,6 +55,7 @@
 #define IDD_GRAPHCFG                    110
 #define IDD_DLLCFG                      111
 #define IDD_DRIVECFG                    112
+#define IDD_DIRECT3DCFG                 113
 #define IDD_DESKTOP_INTEGRATION         115
 #define IDB_WINE_LOGO                   200
 #define IDC_TABABOUT                    1001
@@ -197,6 +199,12 @@
 #define IDC_SYSPARAM_COLOR              1416
 #define IDC_SYSPARAM_FONT               1417
 
+/* direct3d tab */
+#define IDC_D3DLIST			1501
+#define IDC_D3DKEY			1502
+#define IDC_D3DCOMBOVAL			1503
+#define IDC_D3DTIP			1504
+
 #define IDC_SYSPARAMS_BUTTON            8400
 #define IDC_SYSPARAMS_BUTTON_TEXT       8401
 #define IDC_SYSPARAMS_DESKTOP           8402
diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h
index 1959409..6775707 100644
--- a/programs/winecfg/winecfg.h
+++ b/programs/winecfg/winecfg.h
@@ -88,6 +88,7 @@ INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM l
 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK Direct3DDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 /* Drive management  */
 BOOL load_drives(void);
diff --git a/programs/winecfg/winecfg.rc b/programs/winecfg/winecfg.rc
index 4ded308..34baad7 100644
--- a/programs/winecfg/winecfg.rc
+++ b/programs/winecfg/winecfg.rc
@@ -38,6 +38,7 @@ BEGIN
     IDS_TAB_DESKTOP_INTEGRATION "Desktop Integration"
     IDS_TAB_AUDIO           "Audio"
     IDS_TAB_ABOUT           "About"
+    IDS_TAB_DIRECT3D        "Direct3D"
     IDS_WINECFG_TITLE       "Wine configuration"
     IDS_WINECFG_TITLE_APP   "Wine configuration for %s"
     IDS_THEMEFILE           "Theme files (*.msstyles; *.theme)"
@@ -153,6 +154,17 @@ BEGIN
     COMBOBOX        IDC_WINVER,100,194,145,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP    
 END
 
+IDD_DIRECT3DCFG DIALOG  0, 0, 260, 220
+STYLE WS_CHILD | WS_DISABLED
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX        "Direct3D Settings", IDC_STATIC, 8, 4, 244, 210
+    CONTROL         "", IDC_D3DLIST, "SysListView32", WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_SINGLESEL | LVS_REPORT, 15, 51, 148, 116
+    COMBOBOX        IDC_D3DCOMBOVAL, 167, 64, 79, 16, WS_TABSTOP | CBS_DROPDOWN | CBS_HASSTRINGS
+    EDITTEXT        IDC_D3DKEY, 167, 52, 79, 12, NOT WS_BORDER | NOT WS_TABSTOP | ES_READONLY
+    EDITTEXT        IDC_D3DTIP, 15, 174, 232, 36, WS_VSCROLL | NOT WS_TABSTOP | ES_MULTILINE | ES_READONLY
+END
+
 IDD_GRAPHCFG DIALOG  0, 0, 260, 220
 STYLE WS_CHILD | WS_DISABLED
 FONT 8, "MS Shell Dlg"
-- 
1.7.8.3




More information about the wine-devel mailing list