diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index bac55edb8..3e839ed4c 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -74,6 +74,7 @@ #include "gl/dynlights/gl_lightbuffer.h" EXTERN_CVAR(Int, screenblocks) +EXTERN_CVAR(Int, vid_scalemode) CVAR(Bool, gl_scale_viewport, true, CVAR_ARCHIVE); @@ -300,7 +301,7 @@ void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) mSceneViewport.height = height; // Scale viewports to fit letterbox - if ((gl_scale_viewport && !framebuffer->IsFullscreen()) || !FGLRenderBuffers::IsEnabled()) + if ((gl_scale_viewport && !framebuffer->IsFullscreen() && vid_scalemode == 0) || !FGLRenderBuffers::IsEnabled()) { mScreenViewport.width = mOutputLetterbox.width; mScreenViewport.height = mOutputLetterbox.height; diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index a684f4c4c..ba08acaf2 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -55,6 +55,7 @@ EXTERN_CVAR (Float, vid_brightness) EXTERN_CVAR (Float, vid_contrast) EXTERN_CVAR (Bool, vid_vsync) +EXTERN_CVAR(Int, vid_scalemode) CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE) @@ -63,6 +64,8 @@ FGLRenderer *GLRenderer; void gl_LoadExtensions(); void gl_PrintStartupLog(); void gl_SetupMenu(); +int ViewportScaledWidth(int width); +int ViewportScaledHeight(int height); CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) { @@ -180,18 +183,15 @@ void OpenGLFrameBuffer::Update() Unlock(); CheckBench(); - if (!IsFullscreen()) + int clientWidth = ViewportScaledWidth(IsFullscreen() ? VideoWidth : GetClientWidth()); + int clientHeight = ViewportScaledHeight(IsFullscreen() ? VideoHeight : GetClientHeight()); + if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) { - int clientWidth = GetClientWidth(); - int clientHeight = GetClientHeight(); - if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) - { - // Do not call Resize here because it's only for software canvases - Pitch = Width = clientWidth; - Height = clientHeight; - V_OutputResized(Width, Height); - GLRenderer->mVBO->OutputResized(Width, Height); - } + // Do not call Resize here because it's only for software canvases + Pitch = Width = clientWidth; + Height = clientHeight; + V_OutputResized(Width, Height); + GLRenderer->mVBO->OutputResized(Width, Height); } GLRenderer->SetOutputViewport(nullptr); diff --git a/src/menu/videomenu.cpp b/src/menu/videomenu.cpp index 5f139f0af..cc2f72fa6 100644 --- a/src/menu/videomenu.cpp +++ b/src/menu/videomenu.cpp @@ -123,6 +123,37 @@ CUSTOM_CVAR (Bool, vid_tft, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) } } +CUSTOM_CVAR (Int, vid_scalemode, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 3) + { + self = 0; + } +} + +int ViewportScaledWidth(int width) +{ + switch (vid_scalemode) + { + default: + case 0: return width; + case 1: return 320; + case 2: return 640; + case 3: return (int)roundf(width * 0.5f); + } +} + +int ViewportScaledHeight(int height) +{ + switch (vid_scalemode) + { + default: + case 0: return height; + case 1: return 200; + case 2: return 400; + case 3: return (int)roundf(height * 0.5f); + } +} //============================================================================= // diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index d15a20737..ebfa45e3b 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -151,8 +151,8 @@ CUSTOM_CVAR(Bool, fullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) { extern int NewWidth, NewHeight, NewBits, DisplayBits; - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); + NewWidth = screen->VideoWidth; + NewHeight = screen->VideoHeight; NewBits = DisplayBits; setmodeneeded = true; } diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 20ff59325..8e5c44cf4 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -334,8 +334,8 @@ CUSTOM_CVAR(Bool, swtruecolor, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITC CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); + NewWidth = screen->VideoWidth; + NewHeight = screen->VideoHeight; NewBits = DisplayBits; setmodeneeded = true; } @@ -349,8 +349,8 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) else if (Video) { Video->SetWindowedScale (self); - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); + NewWidth = screen->VideoWidth; + NewHeight = screen->VideoHeight; NewBits = DisplayBits; setmodeneeded = true; } diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 599fe00a5..f27c318c4 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -434,8 +434,8 @@ CUSTOM_CVAR(Bool, swtruecolor, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITC CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); + NewWidth = screen->VideoWidth; + NewHeight = screen->VideoHeight; NewBits = DisplayBits; setmodeneeded = true; } @@ -449,8 +449,8 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) else if (Video) { Video->SetWindowedScale (self); - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); + NewWidth = screen->VideoWidth; + NewHeight = screen->VideoHeight; NewBits = DisplayBits; //setmodeneeded = true; // This CVAR doesn't do anything and only causes problems! } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 8071399db..77963a43b 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1260,8 +1260,8 @@ void Win32GLFrameBuffer::NewRefreshRate () if (m_Fullscreen) { setmodeneeded = true; - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); + NewWidth = screen->VideoWidth; + NewHeight = screen->VideoHeight; NewBits = DisplayBits; } } diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 01d316c24..1edd84500 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2191,6 +2191,7 @@ VIDMNU_HIDPI = "Retina/HiDPI support"; VIDMNU_ASPECTRATIO = "Aspect ratio"; VIDMNU_FORCEASPECT = "Force aspect ratio"; VIDMNU_5X4ASPECTRATIO = "Enable 5:4 aspect ratio"; +VIDMNU_SCALEMODE = "Resolution scale"; VIDMNU_ENTERTEXT = "Press ENTER to set mode"; VIDMNU_TESTTEXT1 = "T to test mode for 5 seconds"; VIDMNU_TESTTEXT2 = "Please wait 5 seconds..."; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 148238c9c..f0840fef1 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1849,6 +1849,13 @@ OptionValue RatiosTFT 6.0, "21:9" -1, "$OPTVAL_ALL" } +OptionValue ScaleModes +{ + 0, "$OPTVAL_OFF" + 1, "320x200" + 2, "640x400" + 3, "0.5x" +} OptionMenu VideoModeMenu protected { @@ -1862,6 +1869,7 @@ OptionMenu VideoModeMenu protected Option "$VIDMNU_ASPECTRATIO", "menu_screenratios", "Ratios" Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios" Option "$VIDMNU_5X4ASPECTRATIO", "vid_tft", "YesNo" + Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes" StaticText " " ScreenResolution "res_0" ScreenResolution "res_1"