DXGL r768 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r767‎ | r768 | r769 >
Date:06:03, 6 December 2017
Author:admin
Status:new
Tags:
Comment:
Add configuration variables for custom display scaling.
Modified paths:
  • /cfgmgr/ReadMe.txt (modified) (history)
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /cfgmgr/cfgmgr.h (modified) (history)
  • /dxgl-example.ini (modified) (history)
  • /dxglcfg/dxglcfg.rc (modified) (history)

Diff [purge]

Index: cfgmgr/ReadMe.txt
@@ -26,6 +26,9 @@
2727 5 - Change display mode, aspect corrected stretch if matching mode not found
2828 6 - Change display mode, center if matching mode not found
2929 7 - Crop output to desktop, preserving aspect ratio
 30+8 - Center output, multiply by custom values
 31+9 - Set display to custom resolution and refresh
 32+10 - Center output, scale to custom size
3033
3134 Member fullmode
3235 INI Entry FullscreenWindowMode
@@ -100,6 +103,41 @@
101104 1 - Group by depth
102105 2 - Group by resolution
103106
 107+Member CustomResolutionX
 108+REG_DWORD HKCU\DXGL\Profiles\<app>\CustomResolutionX
 109+INI Entry CustomResolutionX
 110+INI Group display
 111+Width of the custom resolution for the display output for modes 9 and 10.
 112+Default is 640
 113+
 114+Member CustomResolutionY
 115+REG_DWORD HKCU\DXGL\Profiles\<app>\CustomResolutionY
 116+INI Entry CustomResolutionY
 117+INI Group display
 118+Height of the custom resolution for the display output for modes 9 and 10.
 119+Default is 480
 120+
 121+Member CustomRefresh
 122+REG_DWORD HKCU\DXGL\Profiles\<app>\CustomRefresh
 123+INI Entry CustomRefresh
 124+INI Group display
 125+Refresh rate for the display output for modes 9 and 10.
 126+Default is 60
 127+
 128+Member DisplayMultiplierX
 129+REG_DWORD HKCU\DXGL\Profiles\<app>\
 130+INI Entry DisplayMultiplierX
 131+INI Group display
 132+Multiplier for the pixel width for display mode 8.
 133+Default is 1.0
 134+
 135+Member DisplayMultiplierY
 136+REG_DWORD HKCU\DXGL\Profiles\<app>\
 137+INI Entry DisplayMultiplierY
 138+INI Group display
 139+Multiplier for the pixel height for display mode 8.
 140+Default is 1.0
 141+
104142 Member scalingfilter
105143 INI Entry ScalingFilter
106144 INI Group scaling
Index: cfgmgr/cfgmgr.c
@@ -554,6 +554,11 @@
555555 cfg->AddColorDepths = ReadDWORD(hKey,cfg->AddColorDepths,&cfgmask->AddColorDepths,_T("AddColorDepths"));
556556 cfg->AddModes = ReadDeprecatedBool(hKey, cfg->AddModes, &cfgmask->AddModes, _T("ExtraModes"),7,0);
557557 cfg->AddModes = ReadDWORD(hKey, cfg->AddModes, &cfgmask->AddModes, _T("AddModes"));
 558+ cfg->CustomResolutionX = ReadDWORD(hKey, cfg->CustomResolutionX, &cfgmask->CustomResolutionX, _T("CustomResolutionX"));
 559+ cfg->CustomResolutionY = ReadDWORD(hKey, cfg->CustomResolutionY, &cfgmask->CustomResolutionY, _T("CustomResolutionY"));
 560+ cfg->CustomRefresh = ReadDWORD(hKey, cfg->CustomRefresh, &cfgmask->CustomRefresh, _T("CustomRefresh"));
 561+ cfg->DisplayMultiplierX = ReadFloat(hKey, cfg->DisplayMultiplierX, &cfgmask->DisplayMultiplierX, _T("DisplayMultiplierX"));
 562+ cfg->DisplayMultiplierY = ReadFloat(hKey, cfg->DisplayMultiplierY, &cfgmask->DisplayMultiplierY, _T("DisplayMultiplierY"));
558563 cfg->vsync = ReadDWORD(hKey,cfg->vsync,&cfgmask->vsync,_T("VSync"));
559564 cfg->TextureFormat = ReadDWORD(hKey,cfg->TextureFormat,&cfgmask->TextureFormat,_T("TextureFormat"));
560565 cfg->TexUpload = ReadDWORD(hKey,cfg->TexUpload,&cfgmask->TexUpload,_T("TexUpload"));
@@ -677,6 +682,11 @@
678683 WriteDWORD(hKey,cfg->SortModes,cfgmask->SortModes,_T("SortModes"));
679684 WriteDWORD(hKey,cfg->AddColorDepths,cfgmask->AddColorDepths,_T("AddColorDepths"));
680685 WriteDWORD(hKey,cfg->AddModes,cfgmask->AddModes,_T("AddModes"));
 686+ WriteDWORD(hKey, cfg->CustomResolutionX, cfgmask->CustomResolutionX, _T("CustomResolutionX"));
 687+ WriteDWORD(hKey, cfg->CustomResolutionY, cfgmask->CustomResolutionY, _T("CustomResolutionY"));
 688+ WriteDWORD(hKey, cfg->CustomRefresh, cfgmask->CustomRefresh, _T("CustomRefresh"));
 689+ WriteFloat(hKey, cfg->DisplayMultiplierX, cfgmask->DisplayMultiplierX, _T("DisplayMultiplierX"));
 690+ WriteFloat(hKey, cfg->DisplayMultiplierY, cfgmask->DisplayMultiplierX, _T("DisplayMultiplierY"));
681691 WriteDWORD(hKey,cfg->vsync,cfgmask->vsync,_T("VSync"));
682692 WriteDWORD(hKey,cfg->TextureFormat,cfgmask->TextureFormat,_T("TextureFormat"));
683693 WriteDWORD(hKey,cfg->TexUpload,cfgmask->TexUpload,_T("TexUpload"));
@@ -891,6 +901,11 @@
892902 if (!stricmp(name, "PrimaryScaleY")) cfg->primaryscaley = INIFloatValue(value);
893903 if (!stricmp(name, "ScreenAspect")) cfg->aspect = INIAspectValue(value);
894904 if (!stricmp(name, "DPIScale")) cfg->DPIScale = INIIntValue(value);
 905+ if (!stricmp(name, "CustomResolutionX")) cfg->CustomResolutionX = INIIntValue(value);
 906+ if (!stricmp(name, "CustomResolutionY")) cfg->CustomResolutionY = INIIntValue(value);
 907+ if (!stricmp(name, "CustomRefresh")) cfg->CustomRefresh = INIIntValue(value);
 908+ if (!stricmp(name, "DisplayMultiplierX")) cfg->DisplayMultiplierX = INIFloatValue(value);
 909+ if (!stricmp(name, "DisplayMultiplierY")) cfg->DisplayMultiplierY = INIFloatValue(value);
895910 }
896911 if (!stricmp(section, "postprocess"))
897912 {
Index: cfgmgr/cfgmgr.h
@@ -35,6 +35,11 @@
3636 DWORD AddColorDepths;
3737 DWORD AddModes;
3838 DWORD SortModes;
 39+ DWORD CustomResolutionX;
 40+ DWORD CustomResolutionY;
 41+ DWORD CustomRefresh;
 42+ float DisplayMultiplierX;
 43+ float DisplayMultiplierY;
3944 // [scaling]
4045 DWORD scalingfilter;
4146 DWORD primaryscale;
Index: dxgl-example.ini
@@ -65,6 +65,9 @@
6666 ; 5 - Change display mode, aspect corrected stretch if matching mode not found
6767 ; 6 - Change display mode, center if matching mode not found
6868 ; 7 - Crop output to desktop, preserving aspect ratio
 69+; 8 - Center output, multiply by custom values
 70+; 9 - Set display to custom resolution and refresh
 71+; 10 - Center output, scale to custom size
6972 ScalingMode = 0
7073
7174 ; FullscreenWindowMode - Integer
@@ -150,6 +153,31 @@
151154 ; Default is 0.
152155 SortModes = 0
153156
 157+; CustomResolutionX - Integer
 158+; Width of the custom resolution for the display output for modes 9 and 10.
 159+; Default is 640.
 160+CustomResolutionX = 640
 161+
 162+; CustomResolutionY - Integer
 163+; Height of the custom resolution for the display output for modes 9 and 10.
 164+; Default is 480;
 165+CustomResolutionY = 480
 166+
 167+; CustomRefresh - Integer
 168+; Refresh rate for the display output for modes 9 and 10.
 169+; Default is 60.
 170+CustomRefresh = 60
 171+
 172+; DisplayMultiplierX - Floating point
 173+; Multiplier for the pixel width for display mode 8.
 174+; Default is 1.0.
 175+DisplayMultiplierX = 1.0
 176+
 177+; DisplayMultiplierY - Floating point
 178+; Multiplier for the pixel height for display mode 8.
 179+; Default is 1.0.
 180+DisplayMultiplierY = 1.0
 181+
154182 [scaling]
155183 ; ScalingFilter - Integer
156184 ; Selects the filter to be used to scale the output image
Index: dxglcfg/dxglcfg.rc
@@ -76,7 +76,7 @@
7777 LTEXT "Y", IDC_FIXEDSCALELABELY, 57, 97, 8, 9, WS_DISABLED | SS_LEFT, WS_EX_LEFT
7878 EDITTEXT IDC_FIXEDSCALEY, 65, 94, 40, 14, WS_DISABLED | ES_AUTOHSCROLL, WS_EX_LEFT
7979 LTEXT "Custom resolution", 0, 114, 83, 58, 9, SS_LEFT, WS_EX_LEFT
80 - EDITTEXT IDC_CUSTOMMODE, 114, 94, 71, 14, ES_AUTOHSCROLL, WS_EX_LEFT
 80+ EDITTEXT IDC_CUSTOMMODE, 114, 94, 71, 14, WS_DISABLED | ES_AUTOHSCROLL, WS_EX_LEFT
8181 PUSHBUTTON "Select", IDC_SETMODE, 187, 94, 29, 14, WS_DISABLED, WS_EX_LEFT
8282 AUTOCHECKBOX "Change display color depth", IDC_COLOR, 7, 113, 100, 10, 0, WS_EX_LEFT
8383 AUTOCHECKBOX "Single buffered display", IDC_SINGLEBUFFER, 114, 114, 87, 8, 0, WS_EX_LEFT