diff --git a/src/i_video.h b/src/i_video.h index d28289685..25be9ead6 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -141,6 +141,7 @@ void RefreshSDLSurface(void); boolean I_UseNativeKeyboard(void); +void I_DownSample(void); extern boolean downsample; #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c7b26c6ec..2d99aeba3 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -171,8 +171,6 @@ static SDL_bool exposevideo = SDL_FALSE; static SDL_bool usesdl2soft = SDL_FALSE; static SDL_bool borderlesswindow = SDL_FALSE; -static int currentDisplayIndex = -1; - // SDL2 vars SDL_Window *window; SDL_Renderer *renderer; @@ -747,6 +745,35 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return raxis; } +void I_DownSample(void) +{ + if (!cv_grframebuffer.value) + { + downsample = false; + return; + } + + int currentDisplayIndex = SDL_GetWindowDisplayIndex(window); + + SDL_DisplayMode curmode; + if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) == 0) + { + CONS_Printf(" Width: %d\n", curmode.w); + CONS_Printf(" Height: %d\n", curmode.h); + CONS_Printf(" Refresh Rate: %d Hz\n", curmode.refresh_rate); + CONS_Printf(" Display Index: %d\n", currentDisplayIndex); + if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge + { + downsample = true; + RefreshSDLSurface(); + } + else + downsample = false; + } + else + downsample = false; // couldnt get display info so turn the thing off +} + static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { static SDL_bool firsttimeonmouse = SDL_TRUE; @@ -816,24 +843,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) if (windowmoved) { - if (cv_grframebuffer.value) - { - currentDisplayIndex = SDL_GetWindowDisplayIndex(window); - - SDL_DisplayMode curmode; - if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) == 0) - { - if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge - { - downsample = true; - RefreshSDLSurface(); - } - else - downsample = false; - } - else - downsample = false; // couldnt get display info so turn the thing off - } + I_DownSample(); } } @@ -1913,22 +1923,7 @@ INT32 VID_SetMode(INT32 modeNum) } //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); - if (cv_grframebuffer.value) - { - SDL_DisplayMode curmode; - if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) == 0) - { - if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge - { - downsample = true; - RefreshSDLSurface(); // refresh crap so our fbo and screentextures dont break - } - else - downsample = false; - } - else - downsample = false; - } + I_DownSample(); SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); Impl_VideoSetupBuffer(); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index e307bac67..e20ac34ef 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -166,6 +166,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) supportMipMap = true; granisotropicmode_cons_t[1].value = maximumAnisotropy; + + I_DownSample(); } first_init = true;