From 172f58c1655848df85d35676a4a5aeb094d05b2c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Sep 2016 11:46:05 +0200 Subject: [PATCH 1/5] Fix 5:4 aspect ratio gun and status bar --- src/g_shared/shared_sbar.cpp | 2 +- src/r_main.cpp | 4 ++-- src/r_utility.cpp | 2 +- src/v_draw.cpp | 4 ++-- src/v_video.cpp | 19 +++++++++++++------ src/v_video.h | 3 ++- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 3c41d18ca..22171a4bb 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -300,7 +300,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) ST_X = 0; ST_Y = VirticalResolution - RelTop; float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); - if (aspect >= 1.3f) + if (!Is54Aspect(aspect)) { // Normal resolution ::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); } diff --git a/src/r_main.cpp b/src/r_main.cpp index d84698b7c..6094f70de 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -318,7 +318,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth = virtwidth2 = fullWidth; virtheight = virtheight2 = fullHeight; - if (trueratio < 1.3f) + if (Is54Aspect(trueratio)) { virtheight2 = virtheight2 * AspectMultiplier(trueratio) / 48; } @@ -327,7 +327,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth2 = virtwidth2 * AspectMultiplier(trueratio) / 48; } - if (WidescreenRatio < 1.3f) + if (Is54Aspect(WidescreenRatio)) { virtheight = virtheight * AspectMultiplier(WidescreenRatio) / 48; } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 8e4284b7e..76cf05e9b 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -229,7 +229,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) centery = viewheight/2; centerx = viewwidth/2; - if (WidescreenRatio < 1.3f) + if (Is54Aspect(WidescreenRatio)) { centerxwide = centerx; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index a33fd618b..3075cd92d 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -887,7 +887,7 @@ void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h, x = x * Width / vwidth; w = right * Width / vwidth - x; } - if (myratio < 1.3f) + if (Is54Aspect(myratio)) { // The target surface is 5:4 y = (y - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5; h = (bottom - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5 - y; @@ -950,7 +950,7 @@ void DCanvas::FillBorder (FTexture *img) return; } int bordtop, bordbottom, bordleft, bordright, bord; - if (myratio < 1.3f) + if (Is54Aspect(myratio)) { // Screen is taller than it is wide bordleft = bordright = 0; bord = Height - Height * AspectMultiplier(myratio) / 48; diff --git a/src/v_video.cpp b/src/v_video.cpp index 20e1f526c..710d8b1cf 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1362,7 +1362,7 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real int cx1, cy1, cx2, cy2; ratio = ActiveRatio(realwidth, realheight); - if (ratio < 1.3f) + if (Is54Aspect(ratio)) { cwidth = realwidth; cheight = realheight * AspectMultiplier(ratio) / 48; @@ -1703,22 +1703,29 @@ int CheckRatio (int width, int height, int *trueratio) int AspectBaseWidth(float aspect) { - return (int)round(240.0f * aspect * 3.0f); + return !Is54Aspect(aspect) ? (int)round(240.0f * aspect * 3.0f) : 960; } int AspectBaseHeight(float aspect) { - return (int)round(200.0f * (320.0f / (240.0f * aspect)) * 3.0f); + return !Is54Aspect(aspect) ? (int)round(200.0f * (320.0f / (240.0f * aspect)) * 3.0f) : 640; } -int AspectPspriteOffset(float aspect) +double AspectPspriteOffset(float aspect) { - return aspect < 1.3f ? (int)(6.5*FRACUNIT) : 0; + return !Is54Aspect(aspect) ? 0.0 : 6.5; } int AspectMultiplier(float aspect) { - return (int)round(320.0f / (240.0f * aspect) * 48.0f); + return !Is54Aspect(aspect) ? (int)round(320.0f / (240.0f * aspect) * 48.0f) : 48 * 15 / 16; +} + +bool Is54Aspect(float aspect) +{ + // The 5:4 aspect ratio redefined all the values to mean something else.. + // Limit the range this is active to try prevent square cam textures inheriting this madness. + return aspect > 1.1f && aspect < 1.3f; } void IVideo::DumpAdapters () diff --git a/src/v_video.h b/src/v_video.h index 8d785e43f..26d45d9a0 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -523,8 +523,9 @@ static inline double ActiveRatio (double width, double height) { return ActiveRa int AspectBaseWidth(float aspect); int AspectBaseHeight(float aspect); -int AspectPspriteOffset(float aspect); +double AspectPspriteOffset(float aspect); int AspectMultiplier(float aspect); +bool Is54Aspect(float aspect); EXTERN_CVAR(Int, uiscale); From 017d1cee29adf2b2b479cc26dbb8ac5f461f5f0a Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Sep 2016 23:26:30 +0200 Subject: [PATCH 2/5] Change canvas rendering to use the aspect ratio of the canvas and generalize 5:4 rendering as AspectTallerThanWide --- src/g_shared/shared_sbar.cpp | 2 +- src/r_main.cpp | 6 +++--- src/r_utility.cpp | 14 +++++++++++--- src/r_utility.h | 2 +- src/v_draw.cpp | 6 +++--- src/v_video.cpp | 25 ++++++++++++++++--------- src/v_video.h | 2 +- 7 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 22171a4bb..f66ec187d 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -300,7 +300,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) ST_X = 0; ST_Y = VirticalResolution - RelTop; float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); - if (!Is54Aspect(aspect)) + if (!AspectTallerThanWide(aspect)) { // Normal resolution ::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); } diff --git a/src/r_main.cpp b/src/r_main.cpp index 6094f70de..040b57b71 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -318,7 +318,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth = virtwidth2 = fullWidth; virtheight = virtheight2 = fullHeight; - if (Is54Aspect(trueratio)) + if (AspectTallerThanWide(trueratio)) { virtheight2 = virtheight2 * AspectMultiplier(trueratio) / 48; } @@ -327,7 +327,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth2 = virtwidth2 * AspectMultiplier(trueratio) / 48; } - if (Is54Aspect(WidescreenRatio)) + if (AspectTallerThanWide(WidescreenRatio)) { virtheight = virtheight * AspectMultiplier(WidescreenRatio) / 48; } @@ -948,7 +948,7 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, RenderTarget = canvas; bRenderingToCanvas = true; - R_SetWindow (12, width, height, height); + R_SetWindow (12, width, height, height, true); viewwindowx = x; viewwindowy = y; viewactive = true; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 76cf05e9b..ebe36dc9d 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -198,7 +198,7 @@ void R_SetViewSize (int blocks) // //========================================================================== -void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) +void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, bool renderingToCanvas) { float trueratio; @@ -220,7 +220,15 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) freelookviewheight = ((setblocks*fullHeight)/10)&~7; } - WidescreenRatio = ActiveRatio (fullWidth, fullHeight, &trueratio); + if (renderingToCanvas) + { + WidescreenRatio = fullWidth / (float)fullHeight; + trueratio = WidescreenRatio; + } + else + { + WidescreenRatio = ActiveRatio(fullWidth, fullHeight, &trueratio); + } DrawFSHUD = (windowSize == 11); @@ -229,7 +237,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) centery = viewheight/2; centerx = viewwidth/2; - if (Is54Aspect(WidescreenRatio)) + if (AspectTallerThanWide(WidescreenRatio)) { centerxwide = centerx; } diff --git a/src/r_utility.h b/src/r_utility.h index e9fd436e5..09a8b5667 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -95,7 +95,7 @@ void R_ExecuteSetViewSize (void); // Called by M_Responder. void R_SetViewSize (int blocks); -void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight); +void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, bool renderingToCanvas = false); extern void R_FreePastViewers (); diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 3075cd92d..4677c4b08 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -874,7 +874,7 @@ void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h, double right = x + w; double bottom = y + h; - if (myratio > 1.4f) + if (myratio > 1.334f) { // The target surface is either 16:9 or 16:10, so expand the // specified virtual size to avoid undesired stretching of the // image. Does not handle non-4:3 virtual sizes. I'll worry about @@ -887,7 +887,7 @@ void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h, x = x * Width / vwidth; w = right * Width / vwidth - x; } - if (Is54Aspect(myratio)) + if (AspectTallerThanWide(myratio)) { // The target surface is 5:4 y = (y - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5; h = (bottom - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5 - y; @@ -950,7 +950,7 @@ void DCanvas::FillBorder (FTexture *img) return; } int bordtop, bordbottom, bordleft, bordright, bord; - if (Is54Aspect(myratio)) + if (AspectTallerThanWide(myratio)) { // Screen is taller than it is wide bordleft = bordright = 0; bord = Height - Height * AspectMultiplier(myratio) / 48; diff --git a/src/v_video.cpp b/src/v_video.cpp index 710d8b1cf..af190d372 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1362,7 +1362,7 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real int cx1, cy1, cx2, cy2; ratio = ActiveRatio(realwidth, realheight); - if (Is54Aspect(ratio)) + if (AspectTallerThanWide(ratio)) { cwidth = realwidth; cheight = realheight * AspectMultiplier(ratio) / 48; @@ -1703,29 +1703,36 @@ int CheckRatio (int width, int height, int *trueratio) int AspectBaseWidth(float aspect) { - return !Is54Aspect(aspect) ? (int)round(240.0f * aspect * 3.0f) : 960; + return (int)round(240.0f * aspect * 3.0f); } int AspectBaseHeight(float aspect) { - return !Is54Aspect(aspect) ? (int)round(200.0f * (320.0f / (240.0f * aspect)) * 3.0f) : 640; + if (!AspectTallerThanWide(aspect)) + return (int)round(200.0f * (320.0f / (AspectBaseWidth(aspect) / 3.0f)) * 3.0f); + else + return (int)round((200.0f * (4.0f / 3.0f)) / aspect * 3.0f); } double AspectPspriteOffset(float aspect) { - return !Is54Aspect(aspect) ? 0.0 : 6.5; + if (!AspectTallerThanWide(aspect)) + return 0.0; + else + return ((4.0 / 3.0) / aspect - 1.0) * 97.5; } int AspectMultiplier(float aspect) { - return !Is54Aspect(aspect) ? (int)round(320.0f / (240.0f * aspect) * 48.0f) : 48 * 15 / 16; + if (!AspectTallerThanWide(aspect)) + return (int)round(320.0f / (AspectBaseWidth(aspect) / 3.0f) * 48.0f); + else + return (int)round(200.0f / (AspectBaseHeight(aspect) / 3.0f) * 48.0f); } -bool Is54Aspect(float aspect) +bool AspectTallerThanWide(float aspect) { - // The 5:4 aspect ratio redefined all the values to mean something else.. - // Limit the range this is active to try prevent square cam textures inheriting this madness. - return aspect > 1.1f && aspect < 1.3f; + return aspect < 1.333f; } void IVideo::DumpAdapters () diff --git a/src/v_video.h b/src/v_video.h index 26d45d9a0..7317c9d1a 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -525,7 +525,7 @@ int AspectBaseWidth(float aspect); int AspectBaseHeight(float aspect); double AspectPspriteOffset(float aspect); int AspectMultiplier(float aspect); -bool Is54Aspect(float aspect); +bool AspectTallerThanWide(float aspect); EXTERN_CVAR(Int, uiscale); From f1bca9d20e7d36b3057cc9faee7da213d9cbedd0 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Tue, 13 Sep 2016 20:10:06 -0400 Subject: [PATCH 3/5] The old DirectX setup is required to utilize v140_xp. Revert "- removed DirectX setup from CMakeLists for Visual Studio" This reverts commit 954ac8ce5e607e7811a91717e0e1cfe5126d820a. --- src/CMakeLists.txt | 86 ++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb5f21308..7f1554f44 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,59 +114,49 @@ if( WIN32 ) set( FMOD_LIB_PATH_SUFFIXES PATH_SUFFIXES lib ) set( NASM_NAMES nasmw nasm ) - if( NOT MSVC ) - find_path( D3D_INCLUDE_DIR d3d9.h - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Include ) - if( NOT D3D_INCLUDE_DIR ) - message( SEND_ERROR "Could not find DirectX 9 header files" ) - else() - include_directories( ${D3D_INCLUDE_DIR} ) - endif() - - find_path( XINPUT_INCLUDE_DIR xinput.h - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Include ) - if( NOT XINPUT_INCLUDE_DIR ) - message( WARNING "Could not find xinput.h. XInput will be disabled." ) - add_definitions( -DNO_XINPUT ) - else() - include_directories( ${XINPUT_INCLUDE_DIR} ) - endif() - - find_library( DX_dxguid_LIBRARY dxguid - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Lib Lib/${XBITS} ) - find_library( DX_dinput8_LIBRARY dinput8 - PATHS ENV DXSDK_DIR - PATH_SUFFIXES Lib Lib/${XBITS} ) - - set( DX_LIBS_FOUND YES ) - if( NOT DX_dxguid_LIBRARY ) - set( DX_LIBS_FOUND NO ) - endif() - if( NOT DX_dinput8_LIBRARY ) - set( DX_LIBS_FOUND NO ) - endif() - - if( NOT DX_LIBS_FOUND ) - message( FATAL_ERROR "Could not find DirectX 9 libraries" ) - endif() - - set( DX_LIBS - "${DX_dxguid_LIBRARY}" - "${DX_dinput8_LIBRARY}" - ) + find_path( D3D_INCLUDE_DIR d3d9.h + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Include ) + if( NOT D3D_INCLUDE_DIR ) + message( SEND_ERROR "Could not find DirectX 9 header files" ) else() - set( DX_LIBS - dxguid - dinput8 - ) + include_directories( ${D3D_INCLUDE_DIR} ) + endif() + + find_path( XINPUT_INCLUDE_DIR xinput.h + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Include ) + if( NOT XINPUT_INCLUDE_DIR ) + message( WARNING "Could not find xinput.h. XInput will be disabled." ) + add_definitions( -DNO_XINPUT ) + else() + include_directories( ${XINPUT_INCLUDE_DIR} ) endif() - set( ZDOOM_LIBS ${DX_LIBS} + find_library( DX_dxguid_LIBRARY dxguid + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Lib Lib/${XBITS} ) + find_library( DX_dinput8_LIBRARY dinput8 + PATHS ENV DXSDK_DIR + PATH_SUFFIXES Lib Lib/${XBITS} ) + + set( DX_LIBS_FOUND YES ) + if( NOT DX_dxguid_LIBRARY ) + set( DX_LIBS_FOUND NO ) + endif() + if( NOT DX_dinput8_LIBRARY ) + set( DX_LIBS_FOUND NO ) + endif() + + if( NOT DX_LIBS_FOUND ) + message( FATAL_ERROR "Could not find DirectX 9 libraries" ) + endif() + + set( ZDOOM_LIBS wsock32 winmm + "${DX_dxguid_LIBRARY}" + "${DX_dinput8_LIBRARY}" ole32 user32 gdi32 From fd53aefbf27e4ffd2423d027d10f95b3be07dead Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Tue, 13 Sep 2016 20:54:06 -0400 Subject: [PATCH 4/5] Added warning if building on Visual Studio 2015 without v140_xp. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f0bf8293..9d7da1644 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,11 @@ list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ) include( CreateLaunchers ) include( FindPackageHandleStandardArgs ) +# Produce a warning if XP support will be missing. +if( MSVC14 AND NOT CMAKE_GENERATOR_TOOLSET STREQUAL "v140_xp" ) + message( WARNING "This project supports Windows XP (including XP x64), but you must set the optional toolset to v140_xp manually to have it in your build! Use -T \"v140_xp\" from the command prompt." ) +endif() + # Support cross compiling option( FORCE_CROSSCOMPILE "Turn on cross compiling." NO ) if( FORCE_CROSSCOMPILE ) From 3b2359959ef9432448c685cc727039e19d2bf26a Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Tue, 13 Sep 2016 23:06:57 -0500 Subject: [PATCH 5/5] Quakes must use their own independent falloffs.This caused discrepencies and sudden drop-outs in stacked quakes otherwise. --- src/g_shared/a_quake.cpp | 10 ++++------ src/g_shared/a_sharedglobal.h | 1 - 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index aae006ca7..63394e02a 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -291,10 +291,9 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger if (!(quake->m_Flags & QF_WAVE)) { - jiggers.Falloff = MAX(falloff, jiggers.Falloff); - jiggers.RollIntensity = MAX(r, jiggers.RollIntensity) * jiggers.Falloff; + jiggers.RollIntensity = MAX(r, jiggers.RollIntensity) * falloff; - intensity *= jiggers.Falloff; + intensity *= falloff; if (quake->m_Flags & QF_RELATIVE) { jiggers.RelIntensity.X = MAX(intensity.X, jiggers.RelIntensity.X); @@ -310,14 +309,13 @@ int DEarthquake::StaticGetQuakeIntensities(AActor *victim, FQuakeJiggers &jigger } else { - jiggers.Falloff = MAX(falloff, jiggers.Falloff); - jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave) * jiggers.Falloff * strength; + jiggers.RollWave = r * quake->GetModWave(quake->m_RollWave) * falloff * strength; intensity.X *= quake->GetModWave(quake->m_WaveSpeed.X); intensity.Y *= quake->GetModWave(quake->m_WaveSpeed.Y); intensity.Z *= quake->GetModWave(quake->m_WaveSpeed.Z); - intensity *= strength * jiggers.Falloff; + intensity *= strength * falloff; // [RH] This only gives effect to the last sine quake. I would // prefer if some way was found to make multiples coexist diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index 314061f04..029653bb1 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -153,7 +153,6 @@ struct FQuakeJiggers DVector3 RelIntensity; DVector3 Offset; DVector3 RelOffset; - double Falloff; double RollIntensity, RollWave; };