DXGL r417 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r416‎ | r417 | r418 >
Date:01:32, 3 April 2014
Author:admin
Status:new
Tags:
Comment:
Custom aspect calculation for scaling mode 1.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1409,23 +1409,40 @@
14101410 TRACE_EXIT(23,DD_OK);
14111411 return DD_OK;
14121412 break;
1413 - case 2: // Scale to screen
 1413+ case 2: // Scale to screen, aspect corrected
14141414 primaryx = dwWidth;
14151415 screenx = currmode.dmPelsWidth;
14161416 primaryy = dwHeight;
14171417 screeny = currmode.dmPelsHeight;
1418 - aspect = (float)dwWidth / (float)dwHeight;
1419 - xmul = (float)screenx / (float)dwWidth;
1420 - ymul = (float)screeny / (float)dwHeight;
1421 - if((float)dwWidth*(float)ymul > (float)screenx)
 1418+ if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
14221419 {
1423 - internalx = (DWORD)((float)dwWidth * (float)xmul);
1424 - internaly = (DWORD)((float)dwHeight * (float)xmul);
 1420+ aspect = (float)dwWidth / (float)dwHeight;
 1421+ xmul = (float)screenx / (float)dwWidth;
 1422+ ymul = (float)screeny / (float)dwHeight;
 1423+ if ((float)dwWidth*(float)ymul > (float)screenx)
 1424+ {
 1425+ internalx = (DWORD)((float)dwWidth * (float)xmul);
 1426+ internaly = (DWORD)((float)dwHeight * (float)xmul);
 1427+ }
 1428+ else
 1429+ {
 1430+ internalx = (DWORD)((float)dwWidth * (float)ymul);
 1431+ internaly = (DWORD)((float)dwHeight * (float)ymul);
 1432+ }
14251433 }
14261434 else
14271435 {
1428 - internalx = (DWORD)((float)dwWidth * (float)ymul);
1429 - internaly = (DWORD)((float)dwHeight * (float)ymul);
 1436+ aspect = dxglcfg.aspect;
 1437+ if (screenx*aspect > screeny)
 1438+ {
 1439+ internalx = (DWORD)((float)screeny / (float)aspect);
 1440+ internaly = screeny;
 1441+ }
 1442+ else
 1443+ {
 1444+ internalx = screenx;
 1445+ internaly = (DWORD)((float)screenx * (float)aspect);
 1446+ }
14301447 }
14311448 if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
14321449 else internalbpp = screenbpp = currmode.dmBitsPerPel;