From e94ffb4f1022d3d0cdb952669e80c678b8aee3e7 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Sun, 8 Oct 2023 03:00:18 +1000 Subject: [PATCH] Cleanup some legacy cruft in vid_sdl.c Signed-off-by: bones_was_here --- vid.h | 14 +++++---- vid_sdl.c | 88 ++++++++++++++++++++-------------------------------- vid_shared.c | 8 +---- 3 files changed, 42 insertions(+), 68 deletions(-) diff --git a/vid.h b/vid.h index 3cf85379..8ddf76c4 100644 --- a/vid.h +++ b/vid.h @@ -178,18 +178,20 @@ extern struct cvar_s v_color_white_r; extern struct cvar_s v_color_white_g; extern struct cvar_s v_color_white_b; +extern cvar_t gl_info_vendor; +extern cvar_t gl_info_renderer; +extern cvar_t gl_info_version; +extern cvar_t gl_info_extensions; +extern cvar_t gl_info_platform; +extern cvar_t gl_info_driver; + // brand of graphics chip extern const char *gl_vendor; // graphics chip model and other information extern const char *gl_renderer; // begins with 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, or 1.4.0 extern const char *gl_version; -// extensions list, space separated -extern const char *gl_extensions; -// WGL, GLX, or AGL -extern const char *gl_platform; -// name of driver library (opengl32.dll, libGL.so.1, or whatever) -extern char gl_driver[256]; + void *GL_GetProcAddress(const char *name); qbool GL_CheckExtension(const char *name, const char *disableparm, int silent); diff --git a/vid_sdl.c b/vid_sdl.c index 91115ca1..11cc4ac2 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -72,7 +72,6 @@ static qbool vid_usingmouse = false; static qbool vid_usingmouse_relativeworks = false; // SDL2 workaround for unimplemented RelativeMouse mode static qbool vid_usinghidecursor = false; static qbool vid_hasfocus = false; -static qbool vid_isfullscreen; static qbool vid_usingvsync = false; static SDL_Joystick *vid_sdljoystick = NULL; static SDL_GameController *vid_sdlgamecontroller = NULL; @@ -1349,7 +1348,6 @@ void VID_Init (void) vid_sdl_initjoysticksystem = SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0; if (!vid_sdl_initjoysticksystem) Con_Printf(CON_ERROR "Failed to init SDL joystick subsystem: %s\n", SDL_GetError()); - vid_isfullscreen = false; } static int vid_sdljoystickindex = -1; @@ -1472,12 +1470,6 @@ static void AdjustWindowBounds(viddef_mode_t *mode, RECT *rect) } #endif -extern cvar_t gl_info_vendor; -extern cvar_t gl_info_renderer; -extern cvar_t gl_info_version; -extern cvar_t gl_info_platform; -extern cvar_t gl_info_driver; - static qbool VID_InitModeGL(viddef_mode_t *mode) { int windowflags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL; @@ -1487,7 +1479,8 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) int yPos = SDL_WINDOWPOS_UNDEFINED; int i; #ifndef USE_GLES2 - const char *drivername; + // SDL usually knows best + const char *drivername = NULL; #endif win_half_width = mode->width>>1; @@ -1499,9 +1492,6 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) VID_OutputVersion(); #ifndef USE_GLES2 - // SDL usually knows best - drivername = NULL; - // COMMANDLINEOPTION: SDL GL: -gl_driver selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it i = Sys_CheckParm("-gl_driver"); if (i && i < sys.argc - 1) @@ -1520,40 +1510,41 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) windowflags |= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS; #endif - vid_isfullscreen = false; + + if (mode->fullscreen) { - if (mode->fullscreen) { - if (vid_desktopfullscreen.integer) - { - vid_mode_t *m = VID_GetDesktopMode(); - mode->width = m->width; - mode->height = m->height; - windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - } - else - windowflags |= SDL_WINDOW_FULLSCREEN; - vid_isfullscreen = true; + if (vid_desktopfullscreen.integer) + { + vid_mode_t *m = VID_GetDesktopMode(); + mode->width = m->width; + mode->height = m->height; + windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } - else { - if (vid_borderless.integer) - windowflags |= SDL_WINDOW_BORDERLESS; + else + windowflags |= SDL_WINDOW_FULLSCREEN; + } + else + { + if (vid_borderless.integer) + windowflags |= SDL_WINDOW_BORDERLESS; #ifdef WIN32 - if (vid_ignore_taskbar.integer) { - xPos = SDL_WINDOWPOS_CENTERED; - yPos = SDL_WINDOWPOS_CENTERED; - } - else { - RECT rect; - AdjustWindowBounds(mode, &rect); - xPos = rect.left; - yPos = rect.top; - } -#endif + if (vid_ignore_taskbar.integer) + { + xPos = SDL_WINDOWPOS_CENTERED; + yPos = SDL_WINDOWPOS_CENTERED; + } + else + { + RECT rect; + AdjustWindowBounds(mode, &rect); + xPos = rect.left; + yPos = rect.top; } +#endif } - //flags |= SDL_HWSURFACE; - if (vid_mouse_clickthrough.integer && !vid_isfullscreen) + + if (vid_mouse_clickthrough.integer) SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); @@ -1604,16 +1595,14 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) SDL_GL_SetSwapInterval(bound(-1, vid_vsync.integer, 1)); vid_usingvsync = (vid_vsync.integer != 0); - gl_platform = "SDL"; - GL_Setup(); // VorteX: set other info Cvar_SetQuick(&gl_info_vendor, gl_vendor); Cvar_SetQuick(&gl_info_renderer, gl_renderer); Cvar_SetQuick(&gl_info_version, gl_version); - Cvar_SetQuick(&gl_info_platform, gl_platform ? gl_platform : ""); - Cvar_SetQuick(&gl_info_driver, gl_driver); + Cvar_SetQuick(&gl_info_platform, "SDL"); + Cvar_SetQuick(&gl_info_driver, drivername ? drivername : ""); // clear to black (loading plaque will be seen over this) GL_Clear(GL_COLOR_BUFFER_BIT, NULL, 1.0f, 0); @@ -1627,13 +1616,6 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) return true; } -extern cvar_t gl_info_extensions; -extern cvar_t gl_info_vendor; -extern cvar_t gl_info_renderer; -extern cvar_t gl_info_version; -extern cvar_t gl_info_platform; -extern cvar_t gl_info_driver; - qbool VID_InitMode(viddef_mode_t *mode) { // GAME_STEELSTORM specific @@ -1656,10 +1638,6 @@ void VID_Shutdown (void) window = NULL; SDL_QuitSubSystem(SDL_INIT_VIDEO); - - gl_driver[0] = 0; - gl_extensions = ""; - gl_platform = ""; } void VID_Finish (void) diff --git a/vid_shared.c b/vid_shared.c index 0b5c2d38..27e01c70 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -129,7 +129,7 @@ cvar_t gl_info_vendor = {CF_CLIENT | CF_READONLY, "gl_info_vendor", "", "indicat cvar_t gl_info_renderer = {CF_CLIENT | CF_READONLY, "gl_info_renderer", "", "indicates graphics chip model and other information"}; cvar_t gl_info_version = {CF_CLIENT | CF_READONLY, "gl_info_version", "", "indicates version of current renderer. begins with 1.0.0, 1.1.0, 1.2.0, 1.3.1 etc."}; cvar_t gl_info_extensions = {CF_CLIENT | CF_READONLY, "gl_info_extensions", "", "indicates extension list found by engine, space separated."}; -cvar_t gl_info_platform = {CF_CLIENT | CF_READONLY, "gl_info_platform", "", "indicates GL platform: WGL, GLX, or AGL."}; +cvar_t gl_info_platform = {CF_CLIENT | CF_READONLY, "gl_info_platform", "", "indicates GL platform: SDL, SDL, or SDL."}; cvar_t gl_info_driver = {CF_CLIENT | CF_READONLY, "gl_info_driver", "", "name of driver library (opengl32.dll, libGL.so.1, or whatever)."}; cvar_t vid_fullscreen = {CF_CLIENT | CF_ARCHIVE, "vid_fullscreen", "1", "use fullscreen (1) or windowed (0)"}; @@ -191,12 +191,6 @@ const char *gl_vendor; const char *gl_renderer; // begins with 1.0.0, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.3.1, or 1.4.0 const char *gl_version; -// extensions list, space separated -const char *gl_extensions; -// WGL, GLX, or AGL -const char *gl_platform; -// name of driver library (opengl32.dll, libGL.so.1, or whatever) -char gl_driver[256]; #ifndef USE_GLES2 GLboolean (GLAPIENTRY *qglIsBuffer) (GLuint buffer); -- 2.39.2