DXGL r705 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r704‎ | r705 | r706 >
Date:03:43, 28 May 2017
Author:admin
Status:new
Tags:
Comment:
Support first pass scaling on "Change Display Mode"
Fix copyright year of libminhook in ThirdParty.txt
Modified paths:
  • /ThirdParty.txt (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ThirdParty.txt
@@ -101,7 +101,7 @@
102102
103103 Contains the MinHook library, subject to the following license:
104104 MinHook - The Minimalistic API Hooking Library for x64/x86
105 -Copyright (C) 2009-2014 Tsuda Kageyu.
 105+Copyright (C) 2009-2016 Tsuda Kageyu.
106106 All rights reserved.
107107
108108 Redistribution and use in source and binary forms, with or without
Index: ddraw/glDirectDraw.cpp
@@ -353,7 +353,8 @@
354354 {
355355 if(!lpEnumModesCallback) return DDERR_INVALIDPARAMS;
356356 if (dwFlags & 0xFFFFFFFC) return DDERR_INVALIDPARAMS;
357 - bool match;
 357+ BOOL match;
 358+ BOOL scalemodes;
358359 DWORD modenum = 0;
359360 DWORD modemax = 128;
360361 DEVMODE mode;
@@ -367,8 +368,19 @@
368369 ddmode.dwSize = sizeof(DDSURFACEDESC);
369370 ddmode.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
370371 ddmode.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
 372+ if (!_isnan(dxglcfg.firstscalex) && !_isnan(dxglcfg.firstscaley) &&
 373+ (dxglcfg.firstscalex > 0.25f) && (dxglcfg.firstscaley > 0.25f) &&
 374+ (dxglcfg.firstscalex != 1.0f) && (dxglcfg.firstscaley != 1.0f) &&
 375+ ((dxglcfg.scaler == 0) || ((dxglcfg.scaler >= 4) && (dxglcfg.scaler <= 6))))
 376+ scalemodes = TRUE;
 377+ else scalemodes = FALSE;
371378 while(EnumDisplaySettings(NULL,modenum++,&mode))
372379 {
 380+ if (scalemodes)
 381+ {
 382+ mode.dmPelsWidth /= dxglcfg.firstscalex;
 383+ mode.dmPelsHeight /= dxglcfg.firstscaley;
 384+ }
373385 modes[modenum-1] = mode;
374386 if(modenum >= modemax)
375387 {
@@ -404,7 +416,7 @@
405417 }
406418 for(DWORD i = 0; i < modenum; i++)
407419 {
408 - match = true;
 420+ match = TRUE;
409421 if(dwFlags & DDEDM_REFRESHRATES) ddmode.dwRefreshRate = modes[i].dmDisplayFrequency;
410422 else
411423 {
@@ -412,18 +424,18 @@
413425 for(DWORD x = 0; x < i; x++)
414426 if((modes[x].dmBitsPerPel == modes[i].dmBitsPerPel) &&
415427 (modes[x].dmPelsWidth == modes[i].dmPelsWidth) &&
416 - (modes[x].dmPelsHeight == modes[i].dmPelsHeight)) match = false;
 428+ (modes[x].dmPelsHeight == modes[i].dmPelsHeight)) match = FALSE;
417429 }
418430 if(lpDDSurfaceDesc)
419431 {
420432 if(lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)
421 - if(lpDDSurfaceDesc->dwWidth != modes[i].dmPelsWidth) match = false;
 433+ if(lpDDSurfaceDesc->dwWidth != modes[i].dmPelsWidth) match = FALSE;
422434 if(lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)
423 - if(lpDDSurfaceDesc->dwHeight != modes[i].dmPelsHeight) match = false;
 435+ if(lpDDSurfaceDesc->dwHeight != modes[i].dmPelsHeight) match = FALSE;
424436 if(lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)
425 - if(lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount != modes[i].dmBitsPerPel) match = false;
 437+ if(lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount != modes[i].dmBitsPerPel) match = FALSE;
426438 if(lpDDSurfaceDesc->dwFlags & DDSD_REFRESHRATE)
427 - if(lpDDSurfaceDesc->dwRefreshRate != modes[i].dmDisplayFrequency) match = false;
 439+ if(lpDDSurfaceDesc->dwRefreshRate != modes[i].dmDisplayFrequency) match = FALSE;
428440 }
429441 if(match)
430442 {
@@ -942,7 +954,7 @@
943955 HRESULT glDirectDraw7::CreateSurface2(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter, BOOL RecordSurface, int version)
944956 {
945957 HRESULT error;
946 - int mipcount;
 958+ DWORD mipcount;
947959 TRACE_ENTER(5, 14, this, 14, lpDDSurfaceDesc2, 14, lplpDDSurface, 14, pUnkOuter, 22, RecordSurface);
948960 if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
949961 if (!lpDDSurfaceDesc2) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
@@ -1686,10 +1698,10 @@
16871699 {
16881700 case DISP_CHANGE_SUCCESSFUL:
16891701 if (fullscreen) this->currmode = newmode;
1690 - primaryx = screenx = newmode.dmPelsWidth;
1691 - primaryy = screeny = newmode.dmPelsHeight;
1692 - internalx = newmode.dmPelsWidth * xscale;
1693 - internaly = newmode.dmPelsHeight * yscale;
 1702+ primaryx = screenx = newmode.dmPelsWidth / xscale;
 1703+ primaryy = screeny = newmode.dmPelsHeight / yscale;
 1704+ internalx = newmode.dmPelsWidth;
 1705+ internaly = newmode.dmPelsHeight;
16941706 internalbpp = screenbpp = newmode.dmBitsPerPel;
16951707 primarybpp = dwBPP;
16961708 if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
Index: ddraw/glRenderer.cpp
@@ -3342,13 +3342,6 @@
33433343 if(This->ddInterface->GetFullscreen())
33443344 {
33453345 This->ddInterface->GetSizes(sizes);
3346 - viewport[0] = viewport[1] = 0;
3347 - viewport[2] = sizes[4];
3348 - viewport[3] = sizes[5];
3349 - view[0] = (GLfloat)-(sizes[4]-sizes[0])/2;
3350 - view[1] = (GLfloat)(sizes[4]-sizes[0])/2+sizes[0];
3351 - view[2] = (GLfloat)(sizes[5]-sizes[1])/2+sizes[1];
3352 - view[3] = (GLfloat)-(sizes[5]-sizes[1])/2;
33533346 if (_isnan(dxglcfg.firstscalex) || _isnan(dxglcfg.firstscaley) ||
33543347 (dxglcfg.firstscalex < 0.25f) || (dxglcfg.firstscaley < 0.25f))
33553348 {
@@ -3362,6 +3355,13 @@
33633356 This->firstscalex = dxglcfg.firstscalex;
33643357 This->firstscaley = dxglcfg.firstscaley;
33653358 }
 3359+ viewport[0] = viewport[1] = 0;
 3360+ viewport[2] = sizes[4]*This->firstscalex;
 3361+ viewport[3] = sizes[5]*This->firstscaley;
 3362+ view[0] = (GLfloat)-((sizes[4]*This->firstscalex)-sizes[0])/2;
 3363+ view[1] = (GLfloat)((sizes[4]*This->firstscalex)-sizes[0])/2+sizes[0];
 3364+ view[2] = (GLfloat)((sizes[5]*This->firstscaley)-sizes[1])/2+sizes[1];
 3365+ view[3] = (GLfloat)-((sizes[5]*This->firstscaley)-sizes[1])/2;
33663366 }
33673367 else
33683368 {