DXGL r777 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r776‎ | r777 | r778 >
Date:07:05, 15 December 2017
Author:admin
Status:new
Tags:
Comment:
Add maximum OpenGL version to DXGL Config.
Fix combo boxes in Advanced tab of DXGL Config.
Add a prompt to save DXGL Config settings before running a test.
Modified paths:
  • /dxglcfg/common.h (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)
  • /dxglcfg/dxgltest.cpp (modified) (history)

Diff [purge]

Index: dxglcfg/common.h
@@ -69,5 +69,8 @@
7070 #endif
7171
7272 extern HRESULT(WINAPI *_EnableThemeDialogTexture)(HWND hwnd, DWORD dwFlags);
 73+// DXGL Config items for DXGL Test
 74+extern HWND hDialog;
 75+void SaveChanges(HWND hWnd);
7376
7477 #endif //_COMMON_H
Index: dxglcfg/dxglcfg.cpp
@@ -65,7 +65,7 @@
6666 HRESULT(WINAPI *_EnableThemeDialogTexture)(HWND hwnd, DWORD dwFlags) = NULL;
6767 static BOOL ExtraModes_Dropdown = FALSE;
6868 static BOOL ColorDepth_Dropdown = FALSE;
69 -static HWND hDialog = NULL;
 69+HWND hDialog = NULL;
7070 static BOOL EditInterlock = FALSE;
7171
7272
@@ -539,6 +539,106 @@
540540 SendDlgItemMessage(hWnd,DlgItem,CB_SETCURSEL,value,0);
541541 }
542542
 543+void SetGLCombo(HWND hWnd, int DlgItem, DWORD *major, DWORD *minor, DWORD *majormask, DWORD *minormask, DWORD tristate, HWND hDialog)
 544+{
 545+ BOOL badversion = FALSE;
 546+ int position;
 547+ if (tristate && (!majormask || !minormask))
 548+ SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL,
 549+ SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
 550+ else
 551+ {
 552+ switch (*major)
 553+ {
 554+ case 0:
 555+ position = 0;
 556+ break;
 557+ case 2:
 558+ switch (*minor)
 559+ {
 560+ case 0:
 561+ position = 1;
 562+ break;
 563+ case 1:
 564+ position = 2;
 565+ break;
 566+ default:
 567+ badversion = TRUE;
 568+ break;
 569+ }
 570+ break;
 571+ case 3:
 572+ switch (*minor)
 573+ {
 574+ case 0:
 575+ position = 3;
 576+ break;
 577+ case 1:
 578+ position = 4;
 579+ break;
 580+ case 2:
 581+ position = 5;
 582+ break;
 583+ case 3:
 584+ position = 6;
 585+ break;
 586+ default:
 587+ badversion = TRUE;
 588+ break;
 589+ }
 590+ break;
 591+ case 4:
 592+ switch (*minor)
 593+ {
 594+ case 0:
 595+ position = 7;
 596+ break;
 597+ case 1:
 598+ position = 8;
 599+ break;
 600+ case 2:
 601+ position = 9;
 602+ break;
 603+ case 3:
 604+ position = 10;
 605+ break;
 606+ case 4:
 607+ position = 11;
 608+ break;
 609+ case 5:
 610+ position = 12;
 611+ break;
 612+ case 6:
 613+ position = 13;
 614+ break;
 615+ default:
 616+ badversion = TRUE;
 617+ break;
 618+ }
 619+ break;
 620+ default:
 621+ badversion = TRUE;
 622+ break;
 623+ }
 624+ if (badversion)
 625+ {
 626+ *major = 0;
 627+ *minor = 0;
 628+ if (tristate)
 629+ {
 630+ position = SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault);
 631+ *majormask = 0;
 632+ *minormask = 0;
 633+ }
 634+ else position = 0;
 635+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 636+ *dirty = TRUE;
 637+ }
 638+ SendDlgItemMessage(hWnd, DlgItem, CB_SETCURSEL, position, 0);
 639+ }
 640+}
 641+
 642+
543643 void SetFloat3place(HWND hWnd, int DlgItem, float value, float mask)
544644 {
545645 TCHAR number[32];
@@ -678,6 +778,84 @@
679779 }
680780 }
681781
 782+void GetGLCombo(HWND hWnd, int DlgItem, DWORD *major, DWORD *minor, DWORD *majormask, DWORD *minormask)
 783+{
 784+ int value = SendDlgItemMessage(hWnd, DlgItem, CB_GETCURSEL, 0, 0);
 785+ if (value == SendDlgItemMessage(hWnd, DlgItem, CB_FINDSTRING, -1, (LPARAM)strdefault))
 786+ {
 787+ *majormask = 0;
 788+ *minormask = 0;
 789+ *major = 0;
 790+ *minor = 0;
 791+ return;
 792+ }
 793+ else
 794+ {
 795+ *majormask = 1;
 796+ *minormask = 1;
 797+ switch (value)
 798+ {
 799+ case 0:
 800+ *major = 0;
 801+ *minor = 0;
 802+ break;
 803+ case 1:
 804+ *major = 2;
 805+ *minor = 0;
 806+ break;
 807+ case 2:
 808+ *major = 2;
 809+ *minor = 1;
 810+ break;
 811+ case 3:
 812+ *major = 3;
 813+ *minor = 0;
 814+ break;
 815+ case 4:
 816+ *major = 3;
 817+ *minor = 1;
 818+ break;
 819+ case 5:
 820+ *major = 3;
 821+ *minor = 2;
 822+ break;
 823+ case 6:
 824+ *major = 3;
 825+ *minor = 3;
 826+ break;
 827+ case 7:
 828+ *major = 4;
 829+ *minor = 0;
 830+ break;
 831+ case 8:
 832+ *major = 4;
 833+ *minor = 1;
 834+ break;
 835+ case 9:
 836+ *major = 4;
 837+ *minor = 2;
 838+ break;
 839+ case 10:
 840+ *major = 4;
 841+ *minor = 3;
 842+ break;
 843+ case 11:
 844+ *major = 4;
 845+ *minor = 4;
 846+ break;
 847+ case 12:
 848+ *major = 4;
 849+ *minor = 5;
 850+ break;
 851+ case 13:
 852+ *major = 4;
 853+ *minor = 6;
 854+ break;
 855+ }
 856+ return;
 857+ }
 858+}
 859+
682860 float GetFloat(HWND hWnd, int dlgitem, float *mask)
683861 {
684862 TCHAR buffer[32];
@@ -1945,6 +2123,12 @@
19462124 *dirty = TRUE;
19472125 }
19482126 break;
 2127+ case IDC_GLVERSION:
 2128+ GetGLCombo(hWnd, IDC_GLVERSION, &cfg->DebugMaxGLVersionMajor, &cfg->DebugMaxGLVersionMinor,
 2129+ &cfgmask->DebugMaxGLVersionMajor, &cfgmask->DebugMaxGLVersionMinor);
 2130+ EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
 2131+ *dirty = TRUE;
 2132+ break;
19492133 default:
19502134 break;
19512135 }
@@ -2725,7 +2909,38 @@
27262910 SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
27272911 /*_tcscpy(buffer, _T("Disable OpenGL errors (OpenGL 4.6+)"));
27282912 SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);*/
2729 -
 2913+ // Max OpenGL
 2914+ _tcscpy(buffer, _T("Maximum Available"));
 2915+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2916+ _tcscpy(buffer, _T("OpenGL 2.0"));
 2917+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2918+ _tcscpy(buffer, _T("OpenGL 2.1"));
 2919+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2920+ _tcscpy(buffer, _T("OpenGL 3.0"));
 2921+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2922+ _tcscpy(buffer, _T("OpenGL 3.1"));
 2923+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2924+ _tcscpy(buffer, _T("OpenGL 3.2"));
 2925+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2926+ _tcscpy(buffer, _T("OpenGL 3.3"));
 2927+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2928+ _tcscpy(buffer, _T("OpenGL 4.0"));
 2929+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2930+ _tcscpy(buffer, _T("OpenGL 4.1"));
 2931+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2932+ _tcscpy(buffer, _T("OpenGL 4.2"));
 2933+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2934+ _tcscpy(buffer, _T("OpenGL 4.3"));
 2935+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2936+ _tcscpy(buffer, _T("OpenGL 4.4"));
 2937+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2938+ _tcscpy(buffer, _T("OpenGL 4.5"));
 2939+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2940+ _tcscpy(buffer, _T("OpenGL 4.6"));
 2941+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)buffer);
 2942+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, WM_SETTEXT, 0, (LPARAM)buffer);
 2943+ SetGLCombo(hTabs[4], IDC_GLVERSION, &cfg->DebugMaxGLVersionMajor, &cfg->DebugMaxGLVersionMinor,
 2944+ &cfgmask->DebugMaxGLVersionMajor, &cfgmask->DebugMaxGLVersionMinor, FALSE, hWnd);
27302945 // Hacks
27312946 _tcscpy(buffer, _T("Crop 640x480 to 640x400"));
27322947 SendDlgItemMessage(hTabs[5], IDC_HACKSLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
@@ -2732,8 +2947,6 @@
27332948 _tcscpy(buffer, _T("Expand 512x448 to 640x480 when border is blank"));
27342949 SendDlgItemMessage(hTabs[5], IDC_HACKSLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
27352950
2736 - EnableWindow(GetDlgItem(hWnd, IDC_APPLY), FALSE);
2737 -
27382951 // Check install path
27392952 installpath = NULL;
27402953 error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\DXGL"), 0, KEY_READ, &hKey);
@@ -3037,8 +3250,10 @@
30383251 SendDlgItemMessage(hTabs[2], IDC_LOWCOLORRENDER, CB_ADDSTRING, 0, (LPARAM)strdefault);
30393252 SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_ADDSTRING, 0, (LPARAM)strdefault);
30403253 // Advanced tab
3041 - SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_ADDSTRING,0,(LPARAM)strdefault);
3042 - SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_ADDSTRING,0,(LPARAM)strdefault);
 3254+ SendDlgItemMessage(hTabs[3], IDC_TEXTUREFORMAT, CB_ADDSTRING, 0, (LPARAM)strdefault);
 3255+ SendDlgItemMessage(hTabs[3], IDC_TEXUPLOAD, CB_ADDSTRING, 0, (LPARAM)strdefault);
 3256+ // Debug tab
 3257+ SendDlgItemMessage(hTabs[4], IDC_GLVERSION, CB_ADDSTRING, 0, (LPARAM)strdefault);
30433258 }
30443259 else if(!current_app && tristate)
30453260 {
@@ -3087,10 +3302,13 @@
30883303 SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_DELETESTRING,
30893304 SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
30903305 // Advanced tab
3091 - SendDlgItemMessage(hTabs[3],IDC_TEXTUREFORMAT,CB_DELETESTRING,
3092 - SendDlgItemMessage(hTabs[3],IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
3093 - SendDlgItemMessage(hTabs[3],IDC_TEXUPLOAD,CB_DELETESTRING,
3094 - SendDlgItemMessage(hTabs[3],IDC_ASPECT3D,CB_FINDSTRING,-1,(LPARAM)strdefault),0);
 3306+ SendDlgItemMessage(hTabs[3], IDC_TEXTUREFORMAT, CB_DELETESTRING,
 3307+ SendDlgItemMessage(hTabs[3], IDC_TEXTUREFORMAT, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
 3308+ SendDlgItemMessage(hTabs[3], IDC_TEXUPLOAD, CB_DELETESTRING,
 3309+ SendDlgItemMessage(hTabs[3], IDC_TEXUPLOAD, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
 3310+ // Debug tab
 3311+ SendDlgItemMessage(hTabs[3], IDC_GLVERSION, CB_DELETESTRING,
 3312+ SendDlgItemMessage(hTabs[3], IDC_GLVERSION, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
30953313 }
30963314 // Read settings into controls
30973315 // Display tab
@@ -3179,6 +3397,8 @@
31803398 SetCombo(hTabs[3],IDC_TEXUPLOAD,cfg->TexUpload,cfgmask->TexUpload,tristate);
31813399 // Debug tab
31823400 RedrawWindow(GetDlgItem(hTabs[4], IDC_DEBUGLIST), NULL, NULL, RDW_INVALIDATE);
 3401+ SetGLCombo(hTabs[4], IDC_GLVERSION, &cfg->DebugMaxGLVersionMajor, &cfg->DebugMaxGLVersionMinor,
 3402+ &cfgmask->DebugMaxGLVersionMajor, &cfgmask->DebugMaxGLVersionMinor, tristate, hWnd);
31833403 // Hacks tab
31843404 RedrawWindow(GetDlgItem(hTabs[5], IDC_HACKSLIST), NULL, NULL, RDW_INVALIDATE);
31853405 }
Index: dxglcfg/dxgltest.cpp
@@ -392,6 +392,13 @@
393393 }
394394 break;
395395 case IDC_TEST:
 396+ if (IsWindowEnabled(GetDlgItem(hDialog, IDC_APPLY)))
 397+ {
 398+ if(MessageBox(hDialog, _T("You have unsaved changes to your configuration.\r\n\
 399+Do you want to apply them before running this test?"),
 400+ _T("Notice"), MB_YESNO| MB_ICONQUESTION) == IDYES)
 401+ SaveChanges(hDialog);
 402+ }
396403 if(SendDlgItemMessage(hWnd,IDC_RESIZABLE,BM_GETCHECK,0,0)) resizable = true;
397404 else resizable = false;
398405 if (buffer < minbuffer) buffer = minbuffer;