From 877a1f15a9f51dcdfbd311062185fbafe86bdead Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 Mar 2024 09:26:46 +0100 Subject: [PATCH] Revert "multidisplay stuff + only activate framebuffer for downsampling" This reverts commit 5f58e7b3436ae5cd4f879c110cce29a43968ab8a. --- src/i_video.h | 2 -- src/sdl/i_video.c | 79 ++++------------------------------------------- src/sdl/ogl_sdl.c | 29 +++++++++-------- 3 files changed, 20 insertions(+), 90 deletions(-) diff --git a/src/i_video.h b/src/i_video.h index 098d65cf6..2f08e4b1f 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -139,6 +139,4 @@ UINT32 I_GetRefreshRate(void); void RefreshSDLSurface(void); -extern boolean downsample; - #endif diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 5c3ca6738..655769dbd 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -163,6 +163,7 @@ static SDL_bool exposevideo = SDL_FALSE; static SDL_bool usesdl2soft = SDL_FALSE; static SDL_bool borderlesswindow = SDL_FALSE; static SDL_DisplayMode currentDisplayMode; +static SDL_DisplayMode currentWindowMode; // SDL2 vars SDL_Window *window; @@ -214,8 +215,6 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); //static void Impl_SetWindowName(const char *title); static void Impl_SetWindowIcon(void); -boolean downsample = false; - void RefreshSDLSurface(void) { OglSdlSurface(vid.width, vid.height); @@ -230,6 +229,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) Uint32 amask; int bpp = 16; int sw_texture_format = SDL_PIXELFORMAT_ABGR8888; + int index = SDL_GetWindowDisplayIndex(window); realwidth = vid.width; realheight = vid.height; @@ -245,7 +245,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) else if (fullscreen && cv_fullscreen.value == 2) { wasfullscreen = SDL_TRUE; - SDL_SetWindowSize(window, width, height); + SDL_GetDesktopDisplayMode(index, ¤tWindowMode); + SDL_SetWindowSize(window, currentWindowMode.w, currentWindowMode.h); SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); } else // windowed mode @@ -279,7 +280,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) else if (fullscreen && cv_fullscreen.value == 2) { wasfullscreen = SDL_TRUE; - SDL_SetWindowSize(window, width, height); + SDL_GetDesktopDisplayMode(index, ¤tWindowMode); + SDL_SetWindowSize(window, currentWindowMode.w, currentWindowMode.h); SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); } } @@ -796,18 +798,11 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return raxis; } -boolean displayinit = false; - static void Impl_HandleWindowEvent(SDL_WindowEvent evt) { static SDL_bool firsttimeonmouse = SDL_TRUE; static SDL_bool mousefocus = SDL_TRUE; static SDL_bool kbfocus = SDL_TRUE; - static SDL_bool windowmoved = SDL_FALSE; - - static int currentDisplayIndex = -1; - static int previousDisplayIndex = -1; - static int numDisplays = -1; switch (evt.event) { @@ -827,9 +822,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) break; case SDL_WINDOWEVENT_MAXIMIZED: break; - case SDL_WINDOWEVENT_MOVED: - windowmoved = SDL_TRUE; - break; } if (mousefocus && kbfocus) @@ -869,52 +861,6 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) } } - if (windowmoved) - { - currentDisplayIndex = SDL_GetWindowDisplayIndex(window); - - if (!displayinit) // dont need to recheck for new displays i think noone adds a display while playing kart lmkao - { - numDisplays = SDL_GetNumVideoDisplays(); - //CONS_Printf("Number of connected displays: %d\n", numDisplays); - displayinit = true; - } - - if (currentDisplayIndex != previousDisplayIndex) - { - //CONS_Printf("Window has changed displays.\n"); - for (int i = 0; i < numDisplays; ++i) - { - if (currentDisplayIndex == i) - { - SDL_DisplayMode curmode; - if (SDL_GetCurrentDisplayMode(i, &curmode) == 0) - { - //CONS_Printf("Current Display Info:\n"); - //CONS_Printf(" Resolution: %dx%d\n", curmode.w, curmode.h); - //CONS_Printf(" Refresh rate: %d Hz\n", curmode.refresh_rate); - - if (cv_grframebuffer.value && ((vid.width > curmode.w) || (vid.height > curmode.h))) //framebuffer downsampler thinge - { - downsample = true; - RefreshSDLSurface(); - } - else - downsample = false; - - if (cv_fullscreen.value == 2) //exclusive - SDLSetMode(curmode.w, curmode.h, true); - else if (cv_fullscreen.value == 1) //borderless sdl thing - SDLSetMode(vid.width, vid.height, true); - else //windowed mode - SDLSetMode(vid.width, vid.height, false); - } - break; // found our current display break outta here - } - } - previousDisplayIndex = currentDisplayIndex; - } - } } static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) @@ -1954,8 +1900,6 @@ static UINT32 VID_GetRefreshRate(void) INT32 VID_SetMode(INT32 modeNum) { - int index = SDL_GetWindowDisplayIndex(window); - SDL_DisplayMode balls; SDLdoUngrabMouse(); vid.recalc = 1; @@ -1992,17 +1936,6 @@ INT32 VID_SetMode(INT32 modeNum) vid.modenum = -1; } //Impl_SetWindowName("SRB2Kart "VERSIONSTRING); - - if (SDL_GetCurrentDisplayMode(index, &balls) == 0) - { - if (cv_grframebuffer.value && ((vid.width > balls.w) || (vid.height > balls.h))) //framebuffer downsampler thinge - { - downsample = true; - RefreshSDLSurface(); - } - else - downsample = false; - } SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); Impl_VideoSetupBuffer(); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index df6aef9b9..7ffae65e2 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -42,7 +42,6 @@ #include "../i_system.h" #include "hwsym_sdl.h" #include "../m_argv.h" -#include "../i_video.h" #ifdef DEBUG_TO_FILE #include @@ -150,22 +149,22 @@ boolean OglSdlSurface(INT32 w, INT32 h) "- GPU vendor has dropped OpenGL support on your GPU and OS. (Old GPU?)\n" "- GPU drivers are missing or broken. You may need to update your drivers."); } - - if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions)) - pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); - else - maximumAnisotropy = 1; - - SetupGLInfo(); - - SetupGLFunc4(); - - granisotropicmode_cons_t[1].value = maximumAnisotropy; } first_init = true; - SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); + if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions)) + pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); + else + maximumAnisotropy = 1; + + SetupGLInfo(); + SetupGLFunc4(); + + granisotropicmode_cons_t[1].value = maximumAnisotropy; + + SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); + // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) { @@ -183,7 +182,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) RenderToFramebuffer = FrameBufferEnabled; GLFramebuffer_Disable(); - if (RenderToFramebuffer && downsample)//uuuuuuuuhuhuuhuhhuhuuh well changing resolutions can break this thing + if (RenderToFramebuffer) GLFramebuffer_Enable(); HWR_Startup(); @@ -217,7 +216,7 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_DrawScreenFinalTexture(sdlw, sdlh); - if (RenderToFramebuffer && downsample) + if (RenderToFramebuffer) GLFramebuffer_Enable(); SDL_GL_SwapWindow(window);