DXGL r523 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r522‎ | r523 | r524 >
Date:15:12, 7 September 2014
Author:admin
Status:new
Tags:
Comment:
Fix texture filtering in older Direct3D rendering.
Add experimental display crop mode.
Modified paths:
  • /cfgmgr/ReadMe.txt (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /dxglcfg/dxglcfg.c (modified) (history)

Diff [purge]

Index: cfgmgr/ReadMe.txt
@@ -10,6 +10,7 @@
1111 4 - Change display mode, stretch if matching mode not found
1212 5 - Change display mode, aspect corrected stretch if matching mode not found
1313 6 - Change display mode, center if matching mode not found
 14+7 - Crop output to desktop, preserving aspect ratio
1415
1516 Member colormode
1617 REG_DWORD HKCU\DXGL\<app>\ChangeColorDepth
Index: ddraw/glDirect3DDevice.cpp
@@ -1360,7 +1360,7 @@
13611361 SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTFG_POINT);
13621362 break;
13631363 case D3DFILTER_LINEAR:
1364 - SetTextureStageState(0,D3DTSS_MINFILTER,D3DTFG_POINT);
 1364+ SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTFG_LINEAR);
13651365 }
13661366 break;
13671367 case D3DRENDERSTATE_TEXTUREMIN:
Index: ddraw/glDirectDraw.cpp
@@ -1807,6 +1807,51 @@
18081808 break;
18091809 }
18101810 break;
 1811+ case 7: // Crop to screen, aspect corrected
 1812+ primaryx = dwWidth;
 1813+ screenx = currmode.dmPelsWidth;
 1814+ primaryy = dwHeight;
 1815+ screeny = currmode.dmPelsHeight;
 1816+ if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
 1817+ {
 1818+ aspect = (float)dwWidth / (float)dwHeight;
 1819+ xmul = (float)screenx / (float)dwWidth;
 1820+ ymul = (float)screeny / (float)dwHeight;
 1821+ if ((float)dwWidth*(float)ymul < (float)screenx)
 1822+ {
 1823+ internalx = (DWORD)((float)dwWidth * (float)xmul);
 1824+ internaly = (DWORD)((float)dwHeight * (float)xmul);
 1825+ }
 1826+ else
 1827+ {
 1828+ internalx = (DWORD)((float)dwWidth * (float)ymul);
 1829+ internaly = (DWORD)((float)dwHeight * (float)ymul);
 1830+ }
 1831+ }
 1832+ else
 1833+ {
 1834+ aspect = dxglcfg.aspect;
 1835+ if (screenx/aspect < screeny)
 1836+ {
 1837+ internalx = (DWORD)((float)screeny * (float)aspect);
 1838+ internaly = screeny;
 1839+ }
 1840+ else
 1841+ {
 1842+ internalx = screenx;
 1843+ internaly = (DWORD)((float)screenx / (float)aspect);
 1844+ }
 1845+ }
 1846+ if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
 1847+ else internalbpp = screenbpp = currmode.dmBitsPerPel;
 1848+ if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
 1849+ else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
 1850+ primarybpp = dwBPP;
 1851+ InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
 1852+ primarylost = true;
 1853+ TRACE_EXIT(23,DD_OK);
 1854+ return DD_OK;
 1855+ break;
18111856 }
18121857 TRACE_EXIT(23,DDERR_GENERIC);
18131858 ERR(DDERR_GENERIC);
Index: dxglcfg/dxglcfg.c
@@ -531,6 +531,8 @@
532532 SendDlgItemMessage(hWnd,IDC_VIDMODE,CB_ADDSTRING,5,(LPARAM)buffer);
533533 _tcscpy(buffer,_T("Center if mode not found"));
534534 SendDlgItemMessage(hWnd,IDC_VIDMODE,CB_ADDSTRING,6,(LPARAM)buffer);
 535+ _tcscpy(buffer,_T("Crop to screen (experimental)"));
 536+ SendDlgItemMessage(hWnd,IDC_VIDMODE,CB_ADDSTRING,7,(LPARAM)buffer);
535537 SendDlgItemMessage(hWnd,IDC_VIDMODE,CB_SETCURSEL,cfg->scaler,0);
536538 // colormode
537539 if(cfg->colormode) SendDlgItemMessage(hWnd,IDC_COLOR,BM_SETCHECK,BST_CHECKED,0);