From e06f87cf10082e1b0df1f0e6d6a12ead2263a8e5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 24 Jul 2017 08:35:27 +0200 Subject: [PATCH] - Added 0.75x scale mode --- src/gl/renderer/gl_postprocess.cpp | 4 ++-- src/gl/system/gl_swframebuffer.cpp | 24 +++++++++++++----------- src/menu/videomenu.cpp | 18 ++++++++++-------- wadsrc/static/menudef.txt | 3 ++- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp index 6f863ec654..bf054db6d3 100644 --- a/src/gl/renderer/gl_postprocess.cpp +++ b/src/gl/renderer/gl_postprocess.cpp @@ -153,7 +153,7 @@ EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_saturation) EXTERN_CVAR(Int, gl_satformula) -extern bool bSuperSampled; +bool ViewportLinearScale(); void FGLRenderer::RenderScreenQuad() { @@ -856,7 +856,7 @@ void FGLRenderer::DrawPresentTexture(const GL_IRECT &box, bool applyGamma) glViewport(box.left, box.top, box.width, box.height); glActiveTexture(GL_TEXTURE0); - if (bSuperSampled) + if (ViewportLinearScale()) { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index e80a0c7a5d..5d90b7725f 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -95,7 +95,7 @@ EXTERN_CVAR(Int, vid_refreshrate) EXTERN_CVAR(Bool, gl_legacy_mode) EXTERN_CVAR(Int, vid_scalemode) -extern bool bSuperSampled; +bool ViewportLinearScale(); #ifdef WIN32 extern cycle_t BlitCycles; @@ -751,6 +751,18 @@ void OpenGLSWFrameBuffer::Present() FBVERTEX verts[4]; CalcFullscreenCoords(verts, false, 0, 0xFFFFFFFF); SetTexture(0, OutputFB->Texture.get()); + + if (ViewportLinearScale()) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + SetPixelShader(Shaders[SHADER_GammaCorrection].get()); SetAlphaBlend(0); EnableAlphaTest(false); @@ -765,16 +777,6 @@ void OpenGLSWFrameBuffer::Present() glBindFramebuffer(GL_FRAMEBUFFER, OutputFB->Framebuffer); glViewport(0, 0, Width, Height); - if (bSuperSampled) - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } - else - { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - } } //========================================================================== diff --git a/src/menu/videomenu.cpp b/src/menu/videomenu.cpp index bb9fbd6246..dcf594f96e 100644 --- a/src/menu/videomenu.cpp +++ b/src/menu/videomenu.cpp @@ -79,7 +79,6 @@ int testingmode; // Holds time to revert to old mode int OldWidth, OldHeight, OldBits; static FIntCVar DummyDepthCvar (NULL, 0, 0); static uint8_t BitTranslate[32]; -bool bSuperSampled = false; // is this mode supersampled? CUSTOM_CVAR (Int, menu_screenratios, -1, CVAR_ARCHIVE) { @@ -126,14 +125,15 @@ CUSTOM_CVAR (Bool, vid_tft, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR (Int, vid_scalemode, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { - if (self < 0 || self > 4) + if (self < 0 || self > 5) { self = 0; } - if (self == 4) // [SP] hack, for now, but we might add custom modes later and special handling will be needed for that... - bSuperSampled = true; - else - bSuperSampled = false; +} + +bool ViewportLinearScale() +{ + return vid_scalemode == 4 || vid_scalemode == 5; } int ViewportScaledWidth(int width) @@ -145,7 +145,8 @@ int ViewportScaledWidth(int width) case 1: return 320; case 2: return 640; case 3: return (int)roundf(width * 0.5f); - case 4: return width * 2; + case 4: return (int)roundf(width * 0.75f); + case 5: return width * 2; } } @@ -158,7 +159,8 @@ int ViewportScaledHeight(int height) case 1: return 200; case 2: return 400; case 3: return (int)roundf(height * 0.5f); - case 4: return height * 2; + case 4: return (int)roundf(height * 0.75f); + case 5: return height * 2; } } diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 87fd67f6b8..66b58c2c46 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1855,7 +1855,8 @@ OptionValue ScaleModes 1, "320x200" 2, "640x400" 3, "0.5x" - 4, "2x SSAA" + 4, "0.75x" + 5, "2x SSAA" } OptionMenu VideoModeMenu protected