diff --git a/neo/renderer/tr_local.h b/neo/renderer/tr_local.h index b798e260..d16427af 100644 --- a/neo/renderer/tr_local.h +++ b/neo/renderer/tr_local.h @@ -1115,6 +1115,9 @@ const int GRAB_RELATIVEMOUSE = (1 << 2); void GLimp_GrabInput(int flags); bool GLimp_SetSwapInterval( int swapInterval ); + +void GLimp_UpdateWindowSize(); + /* ==================================================================== diff --git a/neo/sys/events.cpp b/neo/sys/events.cpp index d26bb71c..a0d34e49 100644 --- a/neo/sys/events.cpp +++ b/neo/sys/events.cpp @@ -1156,6 +1156,9 @@ sysEvent_t Sys_GetEvent() { case SDL_WINDOWEVENT_FOCUS_LOST: in_hasFocus = false; break; + case SDL_WINDOWEVENT_SIZE_CHANGED: + GLimp_UpdateWindowSize(); + break; } continue; // handle next event diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index df501c3c..ed61827e 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -166,6 +166,7 @@ bool GLimp_Init(glimpParms_t parms) { #if SDL_VERSION_ATLEAST(2, 0, 0) flags |= SDL_WINDOW_ALLOW_HIGHDPI; + flags |= SDL_WINDOW_RESIZABLE; /* Doom3 has the nasty habit of modifying the default framebuffer's alpha channel and then * relying on those modifications in blending operations (using GL_DST_(ONE_MINUS_)ALPHA). @@ -410,21 +411,17 @@ try_again: r_swapInterval.ClearModified(); // for HighDPI, window size and drawable size can differ - int ww=0, wh=0; - SDL_GetWindowSize(window, &ww, &wh); - glConfig.winWidth = ww; - glConfig.winHeight = wh; - SDL_GL_GetDrawableSize(window, &glConfig.vidWidth, &glConfig.vidHeight); + GLimp_UpdateWindowSize(); SetSDLIcon(); // for SDL2 this must be done after creating the window glConfig.isFullscreen = (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN; const char* fsStr = glConfig.isFullscreen ? "fullscreen " : ""; - if ( ww != glConfig.vidWidth ) { - common->Printf( "Got a HighDPI %swindow with physical resolution %d x %d and virtual resolution %d x %d\n", - fsStr, glConfig.vidWidth, glConfig.vidHeight, ww, wh ); + if ( (int)glConfig.winWidth != glConfig.vidWidth ) { + common->Printf( "Got a HighDPI %swindow with physical resolution %d x %d and virtual resolution %g x %g\n", + fsStr, glConfig.vidWidth, glConfig.vidHeight, glConfig.winWidth, glConfig.winHeight ); } else { - common->Printf( "Got a %swindow with resolution %d x %d\n", fsStr, ww, wh ); + common->Printf( "Got a %swindow with resolution %g x %g\n", fsStr, glConfig.winWidth, glConfig.winHeight ); } #else SDL_WM_SetCaption(ENGINE_VERSION, ENGINE_VERSION); @@ -770,3 +767,12 @@ bool GLimp_SetSwapInterval( int swapInterval ) return false; #endif } + +void GLimp_UpdateWindowSize() +{ + int ww=0, wh=0; + SDL_GetWindowSize( window, &ww, &wh ); + glConfig.winWidth = ww; + glConfig.winHeight = wh; + SDL_GL_GetDrawableSize( window, &glConfig.vidWidth, &glConfig.vidHeight ); +} diff --git a/neo/sys/stub/stub_gl.cpp b/neo/sys/stub/stub_gl.cpp index 9a861440..9b3d3290 100644 --- a/neo/sys/stub/stub_gl.cpp +++ b/neo/sys/stub/stub_gl.cpp @@ -398,6 +398,7 @@ void GLimp_ActivateContext() {}; void GLimp_DeactivateContext() {}; void GLimp_GrabInput(int flags) {}; bool GLimp_SetSwapInterval( int swapInterval ) { return false; } +void GLimp_UpdateWindowSize() {} #ifdef _MSC_VER #pragma warning(pop)