- Replace vid_max_width and vid_max_height with vid_scalemode for the GL software framebuffer backend

- Fix a crash if the window was resized before creating a game
- Fix main menu scaling being wrong if the video mode didn't match the unscaled screen size
This commit is contained in:
Magnus Norddahl 2017-07-23 04:23:13 +02:00
parent c3702ae9e7
commit 370e53befe
2 changed files with 19 additions and 14 deletions

View file

@ -94,15 +94,6 @@ EXTERN_CVAR(Float, transsouls)
EXTERN_CVAR(Int, vid_refreshrate) EXTERN_CVAR(Int, vid_refreshrate)
EXTERN_CVAR(Bool, gl_legacy_mode) 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 #ifdef WIN32
extern cycle_t BlitCycles; extern cycle_t BlitCycles;
#endif #endif
@ -110,6 +101,9 @@ extern cycle_t BlitCycles;
void gl_LoadExtensions(); void gl_LoadExtensions();
void gl_PrintStartupLog(); void gl_PrintStartupLog();
int ViewportScaledWidth(int width);
int ViewportScaledHeight(int height);
#ifndef WIN32 #ifndef WIN32
// This has to be in this file because system headers conflict Doom headers // This has to be in this file because system headers conflict Doom headers
DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen) 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) : 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; VertexBuffer = nullptr;
IndexBuffer = nullptr; IndexBuffer = nullptr;
@ -1174,6 +1168,14 @@ void OpenGLSWFrameBuffer::Unlock()
else if (--m_Lock == 0) else if (--m_Lock == 0)
{ {
Buffer = nullptr; 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()) if (!IsFullscreen())
{ {
int clientWidth = ClampWidth(GetClientWidth()); int clientWidth = ViewportScaledWidth(GetClientWidth());
int clientHeight = ClampHeight(GetClientHeight()); int clientHeight = ViewportScaledHeight(GetClientHeight());
if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight)) if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight))
{ {
Resize(clientWidth, clientHeight); Resize(clientWidth, clientHeight);

View file

@ -88,6 +88,9 @@ EXTERN_CVAR(Bool, r_blendmethod)
int active_con_scale(); int active_con_scale();
int ViewportScaledWidth(int width);
int ViewportScaledHeight(int height);
FRenderer *Renderer; FRenderer *Renderer;
EXTERN_CVAR (Bool, swtruecolor) EXTERN_CVAR (Bool, swtruecolor)
@ -782,7 +785,7 @@ void DSimpleCanvas::Unlock ()
//========================================================================== //==========================================================================
DFrameBuffer::DFrameBuffer (int width, int height, bool bgra) DFrameBuffer::DFrameBuffer (int width, int height, bool bgra)
: DSimpleCanvas (width, height, bgra) : DSimpleCanvas (ViewportScaledWidth(width), ViewportScaledHeight(height), bgra)
{ {
LastMS = LastSec = FrameCount = LastCount = LastTic = 0; LastMS = LastSec = FrameCount = LastCount = LastTic = 0;
Accel2D = false; Accel2D = false;
@ -1289,7 +1292,7 @@ bool V_DoModeSetup (int width, int height, int bits)
FFont::StaticPreloadFonts(); FFont::StaticPreloadFonts();
DisplayBits = bits; DisplayBits = bits;
V_UpdateModeSize(width, height); V_UpdateModeSize(screen->GetWidth(), screen->GetHeight());
M_RefreshModesList (); M_RefreshModesList ();