DXGL r761 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r760‎ | r761 | r762 >
Date:07:02, 2 December 2017
Author:admin
Status:new
Tags:
Comment:
Create a tab in DXGL Config for application specific hacks.
Modified paths:
  • /dxglcfg/dxglcfg.c (modified) (history)
  • /dxglcfg/dxglcfg.rc (modified) (history)
  • /dxglcfg/resource.h (modified) (history)
  • /dxgltest/Resource.h (modified) (history)

Diff [purge]

Index: dxglcfg/dxglcfg.c
@@ -1457,6 +1457,136 @@
14581458 return TRUE;
14591459 }
14601460
 1461+void ReadHacksItem(int item, BOOL *value, BOOL *mask)
 1462+{
 1463+ switch (item)
 1464+ {
 1465+ default:
 1466+ *value = FALSE;
 1467+ *mask = FALSE;
 1468+ break;
 1469+ }
 1470+}
 1471+
 1472+void WriteHacksItem(int item, BOOL value, BOOL mask)
 1473+{
 1474+ switch (item)
 1475+ {
 1476+ default:
 1477+ break;
 1478+ }
 1479+}
 1480+
 1481+LRESULT CALLBACK HacksTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 1482+{
 1483+ TCHAR str[64];
 1484+ RECT r;
 1485+ DRAWITEMSTRUCT* drawitem;
 1486+ COLORREF OldTextColor, OldBackColor;
 1487+ BOOL hackvalue, hackmask;
 1488+ DWORD item;
 1489+ switch (Msg)
 1490+ {
 1491+ case WM_INITDIALOG:
 1492+ if (_EnableThemeDialogTexture) _EnableThemeDialogTexture(hWnd, ETDT_ENABLETAB);
 1493+ return TRUE;
 1494+ case WM_MEASUREITEM:
 1495+ switch (wParam)
 1496+ {
 1497+ case IDC_HACKSLIST:
 1498+ ((LPMEASUREITEMSTRUCT)lParam)->itemHeight = GetSystemMetrics(SM_CYMENUCHECK);
 1499+ ((LPMEASUREITEMSTRUCT)lParam)->itemWidth = GetSystemMetrics(SM_CXMENUCHECK);
 1500+ break;
 1501+ default:
 1502+ break;
 1503+ }
 1504+ break;
 1505+ case WM_COMMAND:
 1506+ switch (LOWORD(wParam))
 1507+ {
 1508+ case IDC_HACKSLIST:
 1509+ if ((HIWORD(wParam) == LBN_SELCHANGE) || (HIWORD(wParam) == LBN_DBLCLK))
 1510+ {
 1511+ item = SendDlgItemMessage(hWnd, IDC_HACKSLIST, LB_GETCURSEL, 0, 0);
 1512+ ReadHacksItem(item, &hackvalue, &hackmask);
 1513+ if (tristate)
 1514+ {
 1515+ if (hackvalue && hackmask)
 1516+ {
 1517+ hackvalue = FALSE;
 1518+ hackmask = FALSE;
 1519+ }
 1520+ else if (!hackmask)
 1521+ {
 1522+ hackvalue = FALSE;
 1523+ hackmask = TRUE;
 1524+ }
 1525+ else
 1526+ {
 1527+ hackvalue = TRUE;
 1528+ hackmask = TRUE;
 1529+ }
 1530+ }
 1531+ else
 1532+ {
 1533+ if (hackvalue)
 1534+ hackvalue = FALSE;
 1535+ else hackvalue = TRUE;
 1536+ }
 1537+ WriteHacksItem(item, hackvalue, hackmask);
 1538+ RedrawWindow(GetDlgItem(hWnd, IDC_HACKSLIST), NULL, NULL, RDW_INVALIDATE);
 1539+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 1540+ *dirty = TRUE;
 1541+ }
 1542+ break;
 1543+ default:
 1544+ break;
 1545+ }
 1546+ case WM_DRAWITEM:
 1547+ drawitem = (DRAWITEMSTRUCT*)lParam;
 1548+ switch (wParam)
 1549+ {
 1550+ case IDC_HACKSLIST:
 1551+ OldTextColor = GetTextColor(drawitem->hDC);
 1552+ OldBackColor = GetBkColor(drawitem->hDC);
 1553+ if ((drawitem->itemState & ODS_SELECTED))
 1554+ {
 1555+ SetTextColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
 1556+ SetBkColor(drawitem->hDC, GetSysColor(COLOR_HIGHLIGHT));
 1557+ FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1));
 1558+ }
 1559+ else
 1560+ {
 1561+ SetTextColor(drawitem->hDC, GetSysColor(COLOR_WINDOWTEXT));
 1562+ SetBkColor(drawitem->hDC, GetSysColor(COLOR_WINDOW));
 1563+ FillRect(drawitem->hDC, &drawitem->rcItem, (HBRUSH)(COLOR_WINDOW + 1));
 1564+ }
 1565+ memcpy(&r, &drawitem->rcItem, sizeof(RECT));
 1566+ r.left = r.left + 2;
 1567+ r.right = r.left + GetSystemMetrics(SM_CXMENUCHECK);
 1568+ ReadHacksItem(drawitem->itemID, &hackvalue, &hackmask);
 1569+ DrawCheck(drawitem->hDC, drawitem->itemState & ODS_SELECTED, hackvalue, FALSE, !hackmask, &r);
 1570+ drawitem->rcItem.left += GetSystemMetrics(SM_CXSMICON) + 5;
 1571+ SendDlgItemMessage(hWnd, IDC_HACKSLIST, LB_GETTEXT, drawitem->itemID, (LPARAM)str);
 1572+ DrawText(drawitem->hDC, str, _tcslen(str), &drawitem->rcItem,
 1573+ DT_LEFT | DT_SINGLELINE | DT_VCENTER);
 1574+ drawitem->rcItem.left -= GetSystemMetrics(SM_CXSMICON) + 5;
 1575+ if (drawitem->itemState & ODS_FOCUS) DrawFocusRect(drawitem->hDC, &drawitem->rcItem);
 1576+ SetTextColor(drawitem->hDC, OldTextColor);
 1577+ SetBkColor(drawitem->hDC, OldBackColor);
 1578+ DefWindowProc(hWnd, Msg, wParam, lParam);
 1579+ break;
 1580+ default:
 1581+ break;
 1582+ }
 1583+ break;
 1584+ default:
 1585+ return FALSE;
 1586+ }
 1587+ return TRUE;
 1588+}
 1589+
 1590+
14611591 LRESULT CALLBACK PathsTabCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
14621592 {
14631593 switch (Msg)
@@ -1621,9 +1751,9 @@
16221752 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 3, (LPARAM)&tab);
16231753 tab.pszText = _T("Debug");
16241754 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 4, (LPARAM)&tab);
1625 -/* tab.pszText = _T("Hacks");
 1755+ tab.pszText = _T("Hacks");
16261756 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 5, (LPARAM)&tab);
1627 - tab.pszText = _T("Graphics Tests");
 1757+ /*tab.pszText = _T("Graphics Tests");
16281758 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 6, (LPARAM)&tab);
16291759 tab.pszText = _T("About");
16301760 SendDlgItemMessage(hWnd, IDC_TABS, TCM_INSERTITEM, 7, (LPARAM)&tab);*/
@@ -1633,6 +1763,7 @@
16341764 hTabs[2] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_3DGRAPHICS), hTab, Tab3DCallback);
16351765 hTabs[3] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_ADVANCED), hTab, AdvancedTabCallback);
16361766 hTabs[4] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_DEBUG), hTab, DebugTabCallback);
 1767+ hTabs[5] = CreateDialog(hinstance, MAKEINTRESOURCE(IDD_HACKS), hTab, HacksTabCallback);
16371768 SendDlgItemMessage(hWnd, IDC_TABS, TCM_GETITEMRECT, 0, (LPARAM)&r);
16381769 SetWindowPos(hTabs[0], NULL, r.left, r.bottom + 3, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
16391770 ShowWindow(hTabs[1], SW_HIDE);
Index: dxglcfg/dxglcfg.rc
@@ -136,6 +136,18 @@
137137
138138
139139 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 140+IDD_HACKS DIALOG 0, 0, 340, 169
 141+STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
 142+FONT 8, "Ms Shell Dlg"
 143+{
 144+ LTEXT "These options should be set only for specific programs; use with other programs may cause malfuncion.", 0, 7, 5, 328, 9, SS_LEFT, WS_EX_LEFT
 145+ LISTBOX IDC_HACKSLIST, 7, 16, 269, 148, WS_TABSTOP | WS_VSCROLL | LBS_NOINTEGRALHEIGHT |
 146+ LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOTIFY, WS_EX_LEFT
 147+}
 148+
 149+
 150+
 151+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
140152 IDD_EFFECTS DIALOG 0, 0, 340, 169
141153 STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
142154 FONT 8, "Ms Shell Dlg"
Index: dxglcfg/resource.h
@@ -29,6 +29,7 @@
3030 #define IDD_3DGRAPHICS 203
3131 #define IDD_ADVANCED 204
3232 #define IDD_DEBUG 205
 33+#define IDD_HACKS 206
3334
3435 // Icons
3536 #define IDI_DXGL 301
@@ -97,3 +98,5 @@
9899 #define IDC_DEBUGLIST 2401
99100 #define IDC_GLVERSION 2402
100101
 102+// Controls - Hacks Tab
 103+#define IDC_HACKSLIST 2501
Index: dxgltest/Resource.h
@@ -41,131 +41,131 @@
4242 #define IDC_TABS 1002
4343
4444 // Controls - Graphics Tests Tab
45 -#define IDC_TESTLIST 2501
46 -#define IDC_VIDMODES 2502
47 -#define IDC_WINDOWED 2503
48 -#define IDC_FULLSCREEN 2504
49 -#define IDC_RESIZABLE 2505
50 -#define IDC_TESTVSYNC 2506
51 -#define IDC_APIVER 2507
52 -#define IDC_SPINAPI 2508
53 -#define IDC_BUFFERS 2509
54 -#define IDC_SPINBACK 2510
55 -#define IDC_FRAMERATE 2511
56 -#define IDC_SPINFRAME 2512
57 -#define IDC_FILTERLABEL 2513
58 -#define IDC_FILTER 2514
59 -#define IDC_FSAALABEL 2515
60 -#define IDC_FSAA 2516
61 -#define IDC_TEST 2517
 45+#define IDC_TESTLIST 2601
 46+#define IDC_VIDMODES 2602
 47+#define IDC_WINDOWED 2603
 48+#define IDC_FULLSCREEN 2604
 49+#define IDC_RESIZABLE 2605
 50+#define IDC_TESTVSYNC 2606
 51+#define IDC_APIVER 2607
 52+#define IDC_SPINAPI 2608
 53+#define IDC_BUFFERS 2609
 54+#define IDC_SPINBACK 2610
 55+#define IDC_FRAMERATE 2611
 56+#define IDC_SPINFRAME 2612
 57+#define IDC_FILTERLABEL 2613
 58+#define IDC_FILTER 2614
 59+#define IDC_FSAALABEL 2615
 60+#define IDC_FSAA 2616
 61+#define IDC_TEST 2617
6262
6363 // Controls - System Information Tab
64 -#define IDC_DDTYPE 2601
65 -#define IDC_DDVER 2602
66 -#define IDC_DXDIAG 2603
 64+#define IDC_DDTYPE 2701
 65+#define IDC_DDVER 2702
 66+#define IDC_DXDIAG 2703
6767
6868 // Controls - Shader Test Dialog Common
69 -#define IDC_DISPLAY 2701
70 -#define IDC_TEXTURE 2702
71 -#define IDC_TEXTUREFILE 2703
72 -#define IDC_TEXTUREBROWSE 2704
73 -#define IDC_VERTEXFOGMODE 2705
74 -#define IDC_PIXELFOGMODE 2706
75 -#define IDC_FOGSTART 2707
76 -#define IDC_FOGEND 2708
77 -#define IDC_FOGDENSITY 2709
78 -#define IDC_RANGEBASEDFOG 2710
79 -#define IDC_FOGENABLE 2711
80 -#define IDC_DIFFUSE 2712
81 -#define IDC_DIFFUSESELECT 2713
82 -#define IDC_SPECULAR 2714
83 -#define IDC_SPECULARSELECT 2715
84 -#define IDC_FACTOR 2716
85 -#define IDC_FACTORSELECT 2717
86 -#define IDC_FOGCOLOR 2718
87 -#define IDC_FOGCOLORSELECT 2719
88 -#define IDC_BGCOLOR 2720
89 -#define IDC_BGCOLORSELECT 2721
 69+#define IDC_DISPLAY 2801
 70+#define IDC_TEXTURE 2802
 71+#define IDC_TEXTUREFILE 2803
 72+#define IDC_TEXTUREBROWSE 2804
 73+#define IDC_VERTEXFOGMODE 2805
 74+#define IDC_PIXELFOGMODE 2806
 75+#define IDC_FOGSTART 2807
 76+#define IDC_FOGEND 2808
 77+#define IDC_FOGDENSITY 2809
 78+#define IDC_RANGEBASEDFOG 2810
 79+#define IDC_FOGENABLE 2811
 80+#define IDC_DIFFUSE 2812
 81+#define IDC_DIFFUSESELECT 2813
 82+#define IDC_SPECULAR 2814
 83+#define IDC_SPECULARSELECT 2815
 84+#define IDC_FACTOR 2816
 85+#define IDC_FACTORSELECT 2817
 86+#define IDC_FOGCOLOR 2818
 87+#define IDC_FOGCOLORSELECT 2819
 88+#define IDC_BGCOLOR 2820
 89+#define IDC_BGCOLORSELECT 2821
9090
9191
9292 // Controls - Texture Shader Test Dialog
93 -#define IDC_TEXSTAGE 2801
94 -#define IDC_SPINSTAGE 2802
95 -#define IDC_TEXCOLORKEY 2803
96 -#define IDC_SETTEXCOLORKEY 2804
97 -#define IDC_CARG1 2805
98 -#define IDC_CARG1INV 2806
99 -#define IDC_CARG1A 2807
100 -#define IDC_CARG2 2808
101 -#define IDC_CARG2INV 2809
102 -#define IDC_CARG2A 2810
103 -#define IDC_COLOROP 2811
104 -#define IDC_AARG1 2812
105 -#define IDC_AARG1INV 2813
106 -#define IDC_AARG1A 2814
107 -#define IDC_AARG2 2815
108 -#define IDC_AARG2INV 2816
109 -#define IDC_AARG2A 2817
110 -#define IDC_ALPHAOP 2818
111 -#define IDC_TEXTUREPREVIEW 2819
112 -#define IDC_ALPHABLEND 2820
113 -#define IDC_SRCBLEND 2821
114 -#define IDC_DESTBLEND 2822
115 -#define IDC_ALPHAREF 2823
116 -#define IDC_SPINALPHAREF 2824
117 -#define IDC_ALPHAFUNC 2825
118 -#define IDC_ALPHASTIPPLE 2826
119 -#define IDC_ALPHATEST 2827
120 -#define IDC_COLORKEY 2828
121 -#define IDC_COLORKEYBLEND 2829
122 -#define IDC_LINESTIPPLEPATTERN 2830
123 -#define IDC_LINESTIPPLEREPEAT 2831
124 -#define IDC_SPINLINEREPEAT 2832
125 -#define IDC_FILLSTIPPLELLLABEL 2833
126 -#define IDC_FILLSTIPPLETYPE 2834
127 -#define IDC_FILLSTIPPLEFILE 2835
128 -#define IDC_FILLSTIPPLEBROWSE 2836
129 -#define IDC_FILLSTIPPLEPREVIEW 2837
 93+#define IDC_TEXSTAGE 2901
 94+#define IDC_SPINSTAGE 2902
 95+#define IDC_TEXCOLORKEY 2903
 96+#define IDC_SETTEXCOLORKEY 2904
 97+#define IDC_CARG1 2905
 98+#define IDC_CARG1INV 2906
 99+#define IDC_CARG1A 2907
 100+#define IDC_CARG2 2908
 101+#define IDC_CARG2INV 2909
 102+#define IDC_CARG2A 2910
 103+#define IDC_COLOROP 2911
 104+#define IDC_AARG1 2912
 105+#define IDC_AARG1INV 2913
 106+#define IDC_AARG1A 2914
 107+#define IDC_AARG2 2915
 108+#define IDC_AARG2INV 2916
 109+#define IDC_AARG2A 2917
 110+#define IDC_ALPHAOP 2918
 111+#define IDC_TEXTUREPREVIEW 2919
 112+#define IDC_ALPHABLEND 2920
 113+#define IDC_SRCBLEND 2921
 114+#define IDC_DESTBLEND 2922
 115+#define IDC_ALPHAREF 2923
 116+#define IDC_SPINALPHAREF 2924
 117+#define IDC_ALPHAFUNC 2925
 118+#define IDC_ALPHASTIPPLE 2926
 119+#define IDC_ALPHATEST 2927
 120+#define IDC_COLORKEY 2928
 121+#define IDC_COLORKEYBLEND 2929
 122+#define IDC_LINESTIPPLEPATTERN 2930
 123+#define IDC_LINESTIPPLEREPEAT 2931
 124+#define IDC_SPINLINEREPEAT 2932
 125+#define IDC_FILLSTIPPLELLLABEL 2933
 126+#define IDC_FILLSTIPPLETYPE 2934
 127+#define IDC_FILLSTIPPLEFILE 2935
 128+#define IDC_FILLSTIPPLEBROWSE 2936
 129+#define IDC_FILLSTIPPLEPREVIEW 2937
130130
131131 // Controls - Vertex Test Dialog
132 -#define IDC_AMBIENT 2901
133 -#define IDC_AMBIENTSELECT 2902
134 -#define IDC_EMISSIVE 2903
135 -#define IDC_EMISSIVESELECT 2904
136 -#define IDC_MATAMBIENT 2905
137 -#define IDC_MATAMBIENTSELECT 2906
138 -#define IDC_MATDIFFUSE 2907
139 -#define IDC_MATDIFFUSESELECT 2908
140 -#define IDC_MATSPECULAR 2909
141 -#define IDC_MATSPECULARSELECT 2910
142 -#define IDC_FILLMODE 2911
143 -#define IDC_SHADEMODE 2912
144 -#define IDC_CULLMODE 2913
145 -#define IDC_ENABLELIGHT 2914
146 -#define IDC_ENABLESPECULAR 2915
147 -#define IDC_VERTEXCOLOR 2916
148 -#define IDC_LOCALVIEWER 2917
149 -#define IDC_DETAIL 2918
150 -#define IDC_SPINDETAIL 2919
151 -#define IDC_DIFFUSESOURCE 2920
152 -#define IDC_AMBIENTSOURCE 2921
153 -#define IDC_SPECULARSOURCE 2922
154 -#define IDC_EMISSIVESOURCE 2923
155 -#define IDC_LIGHTNUMBER 2924
156 -#define IDC_SPINLIGHT 2925
157 -#define IDC_LIGHTDIFFUSE 2926
158 -#define IDC_LIGHTDIFFUSESELECT 2927
159 -#define IDC_LIGHTAMBIENT 2928
160 -#define IDC_LIGHTAMBIENTSELECT 2929
161 -#define IDC_LIGHTTYPE 2930
162 -#define IDC_LIGHTSPECULAR 2931
163 -#define IDC_LIGHTSPECULARSELECT 2932
164 -#define IDC_LIGHTRANGE 2933
165 -#define IDC_LIGHTENABLED 2934
166 -#define IDC_POWER 2935
167 -#define IDC_LIGHTFALLOFF 2936
168 -#define IDC_LIGHTATTEN0 2937
169 -#define IDC_LIGHTATTEN1 2938
170 -#define IDC_LIGHTATTEN2 2939
171 -#define IDC_LIGHTTHETA 2940
172 -#define IDC_LIGHTPHI 2941
 132+#define IDC_AMBIENT 3001
 133+#define IDC_AMBIENTSELECT 3002
 134+#define IDC_EMISSIVE 3003
 135+#define IDC_EMISSIVESELECT 3004
 136+#define IDC_MATAMBIENT 3005
 137+#define IDC_MATAMBIENTSELECT 3006
 138+#define IDC_MATDIFFUSE 3007
 139+#define IDC_MATDIFFUSESELECT 3008
 140+#define IDC_MATSPECULAR 3009
 141+#define IDC_MATSPECULARSELECT 3010
 142+#define IDC_FILLMODE 3011
 143+#define IDC_SHADEMODE 3012
 144+#define IDC_CULLMODE 3013
 145+#define IDC_ENABLELIGHT 3014
 146+#define IDC_ENABLESPECULAR 3015
 147+#define IDC_VERTEXCOLOR 3016
 148+#define IDC_LOCALVIEWER 3017
 149+#define IDC_DETAIL 3018
 150+#define IDC_SPINDETAIL 3019
 151+#define IDC_DIFFUSESOURCE 3020
 152+#define IDC_AMBIENTSOURCE 3021
 153+#define IDC_SPECULARSOURCE 3022
 154+#define IDC_EMISSIVESOURCE 3023
 155+#define IDC_LIGHTNUMBER 3024
 156+#define IDC_SPINLIGHT 3025
 157+#define IDC_LIGHTDIFFUSE 3026
 158+#define IDC_LIGHTDIFFUSESELECT 3027
 159+#define IDC_LIGHTAMBIENT 3028
 160+#define IDC_LIGHTAMBIENTSELECT 3029
 161+#define IDC_LIGHTTYPE 3030
 162+#define IDC_LIGHTSPECULAR 3031
 163+#define IDC_LIGHTSPECULARSELECT 3032
 164+#define IDC_LIGHTRANGE 3033
 165+#define IDC_LIGHTENABLED 3034
 166+#define IDC_POWER 3035
 167+#define IDC_LIGHTFALLOFF 3036
 168+#define IDC_LIGHTATTEN0 3037
 169+#define IDC_LIGHTATTEN1 3038
 170+#define IDC_LIGHTATTEN2 3039
 171+#define IDC_LIGHTTHETA 3040
 172+#define IDC_LIGHTPHI 3041