mirror of
https://github.com/dhewm/dhewm3.git
synced 2024-11-29 07:32:25 +00:00
Make dhewm3 window resizable (when using SDL2)
is this really all that's needed?!
This commit is contained in:
parent
28b753d50b
commit
ab676878b9
4 changed files with 22 additions and 9 deletions
|
@ -1115,6 +1115,9 @@ const int GRAB_RELATIVEMOUSE = (1 << 2);
|
||||||
void GLimp_GrabInput(int flags);
|
void GLimp_GrabInput(int flags);
|
||||||
|
|
||||||
bool GLimp_SetSwapInterval( int swapInterval );
|
bool GLimp_SetSwapInterval( int swapInterval );
|
||||||
|
|
||||||
|
void GLimp_UpdateWindowSize();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================================================================
|
====================================================================
|
||||||
|
|
||||||
|
|
|
@ -1156,6 +1156,9 @@ sysEvent_t Sys_GetEvent() {
|
||||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||||
in_hasFocus = false;
|
in_hasFocus = false;
|
||||||
break;
|
break;
|
||||||
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
|
GLimp_UpdateWindowSize();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue; // handle next event
|
continue; // handle next event
|
||||||
|
|
|
@ -166,6 +166,7 @@ bool GLimp_Init(glimpParms_t parms) {
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||||
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
flags |= SDL_WINDOW_ALLOW_HIGHDPI;
|
||||||
|
flags |= SDL_WINDOW_RESIZABLE;
|
||||||
|
|
||||||
/* Doom3 has the nasty habit of modifying the default framebuffer's alpha channel and then
|
/* 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).
|
* relying on those modifications in blending operations (using GL_DST_(ONE_MINUS_)ALPHA).
|
||||||
|
@ -410,21 +411,17 @@ try_again:
|
||||||
r_swapInterval.ClearModified();
|
r_swapInterval.ClearModified();
|
||||||
|
|
||||||
// for HighDPI, window size and drawable size can differ
|
// for HighDPI, window size and drawable size can differ
|
||||||
int ww=0, wh=0;
|
GLimp_UpdateWindowSize();
|
||||||
SDL_GetWindowSize(window, &ww, &wh);
|
|
||||||
glConfig.winWidth = ww;
|
|
||||||
glConfig.winHeight = wh;
|
|
||||||
SDL_GL_GetDrawableSize(window, &glConfig.vidWidth, &glConfig.vidHeight);
|
|
||||||
|
|
||||||
SetSDLIcon(); // for SDL2 this must be done after creating the window
|
SetSDLIcon(); // for SDL2 this must be done after creating the window
|
||||||
|
|
||||||
glConfig.isFullscreen = (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN;
|
glConfig.isFullscreen = (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN;
|
||||||
const char* fsStr = glConfig.isFullscreen ? "fullscreen " : "";
|
const char* fsStr = glConfig.isFullscreen ? "fullscreen " : "";
|
||||||
if ( ww != glConfig.vidWidth ) {
|
if ( (int)glConfig.winWidth != glConfig.vidWidth ) {
|
||||||
common->Printf( "Got a HighDPI %swindow with physical resolution %d x %d and virtual resolution %d x %d\n",
|
common->Printf( "Got a HighDPI %swindow with physical resolution %d x %d and virtual resolution %g x %g\n",
|
||||||
fsStr, glConfig.vidWidth, glConfig.vidHeight, ww, wh );
|
fsStr, glConfig.vidWidth, glConfig.vidHeight, glConfig.winWidth, glConfig.winHeight );
|
||||||
} else {
|
} 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
|
#else
|
||||||
SDL_WM_SetCaption(ENGINE_VERSION, ENGINE_VERSION);
|
SDL_WM_SetCaption(ENGINE_VERSION, ENGINE_VERSION);
|
||||||
|
@ -770,3 +767,12 @@ bool GLimp_SetSwapInterval( int swapInterval )
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#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 );
|
||||||
|
}
|
||||||
|
|
|
@ -398,6 +398,7 @@ void GLimp_ActivateContext() {};
|
||||||
void GLimp_DeactivateContext() {};
|
void GLimp_DeactivateContext() {};
|
||||||
void GLimp_GrabInput(int flags) {};
|
void GLimp_GrabInput(int flags) {};
|
||||||
bool GLimp_SetSwapInterval( int swapInterval ) { return false; }
|
bool GLimp_SetSwapInterval( int swapInterval ) { return false; }
|
||||||
|
void GLimp_UpdateWindowSize() {}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
Loading…
Reference in a new issue