diff --git a/src/gl/system/gl_swframebuffer.cpp b/src/gl/system/gl_swframebuffer.cpp index c0ed43211..c426e01e4 100644 --- a/src/gl/system/gl_swframebuffer.cpp +++ b/src/gl/system/gl_swframebuffer.cpp @@ -94,15 +94,6 @@ EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Int, vid_refreshrate) EXTERN_CVAR(Bool, gl_legacy_mode) -CVAR(Int, vid_max_width, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -CVAR(Int, vid_max_height, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) - -namespace -{ - int ClampWidth(int width) { return (vid_max_width == 0 || width < vid_max_width) ? width : vid_max_width; } - int ClampHeight(int height) { return (vid_max_height == 0 || height < vid_max_height) ? height : vid_max_height; } -} - #ifdef WIN32 extern cycle_t BlitCycles; #endif @@ -110,6 +101,9 @@ extern cycle_t BlitCycles; void gl_LoadExtensions(); void gl_PrintStartupLog(); +int ViewportScaledWidth(int width); +int ViewportScaledHeight(int height); + #ifndef WIN32 // This has to be in this file because system headers conflict Doom headers DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen) @@ -147,7 +141,7 @@ const char *const OpenGLSWFrameBuffer::ShaderDefines[OpenGLSWFrameBuffer::NUM_SH }; OpenGLSWFrameBuffer::OpenGLSWFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra) : - Super(hMonitor, ClampWidth(width), ClampHeight(height), bits, refreshHz, fullscreen, bgra) + Super(hMonitor, width, height, bits, refreshHz, fullscreen, bgra) { VertexBuffer = nullptr; IndexBuffer = nullptr; @@ -1174,6 +1168,14 @@ void OpenGLSWFrameBuffer::Unlock() else if (--m_Lock == 0) { Buffer = nullptr; + + if (MappedMemBuffer) + { + BindFBBuffer(); + glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + MappedMemBuffer = nullptr; + } } } @@ -1283,8 +1285,8 @@ void OpenGLSWFrameBuffer::Flip() if (!IsFullscreen()) { - int clientWidth = ClampWidth(GetClientWidth()); - int clientHeight = ClampHeight(GetClientHeight()); + int clientWidth = ViewportScaledWidth(GetClientWidth()); + int clientHeight = ViewportScaledHeight(GetClientHeight()); if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) { Resize(clientWidth, clientHeight); diff --git a/src/v_video.cpp b/src/v_video.cpp index 44f634d00..028973aac 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -88,6 +88,9 @@ EXTERN_CVAR(Bool, r_blendmethod) int active_con_scale(); +int ViewportScaledWidth(int width); +int ViewportScaledHeight(int height); + FRenderer *Renderer; EXTERN_CVAR (Bool, swtruecolor) @@ -782,7 +785,7 @@ void DSimpleCanvas::Unlock () //========================================================================== DFrameBuffer::DFrameBuffer (int width, int height, bool bgra) - : DSimpleCanvas (width, height, bgra) + : DSimpleCanvas (ViewportScaledWidth(width), ViewportScaledHeight(height), bgra) { LastMS = LastSec = FrameCount = LastCount = LastTic = 0; Accel2D = false; @@ -1289,7 +1292,7 @@ bool V_DoModeSetup (int width, int height, int bits) FFont::StaticPreloadFonts(); DisplayBits = bits; - V_UpdateModeSize(width, height); + V_UpdateModeSize(screen->GetWidth(), screen->GetHeight()); M_RefreshModesList ();