From: bones_was_here Date: Sat, 14 Oct 2023 16:43:38 +0000 (+1000) Subject: vid: misc cleanups X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=406899eb226c2aaf9ff20abdccb6e6823b02b376;p=xonotic%2Fdarkplaces.git vid: misc cleanups Signed-off-by: bones_was_here --- diff --git a/cl_demo.c b/cl_demo.c index beab8f84..927e85b5 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern cvar_t cl_capturevideo; extern cvar_t cl_capturevideo_demo_stop; #endif -int old_vsync = 0; static void CL_FinishTimeDemo (void); diff --git a/host.c b/host.c index a20903a9..9a39d8bf 100644 --- a/host.c +++ b/host.c @@ -644,7 +644,7 @@ static double Host_Frame(double time) Curl_Frame(); // get new SDL events and add commands from keybindings to the cbuf - Sys_SendKeyEvents(); + Sys_SDL_HandleEvents(); // process console commands Cbuf_Frame(host.cbuf); diff --git a/mvm_cmds.c b/mvm_cmds.c index 3faf9a1f..e3442831 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -193,19 +193,10 @@ static void VM_M_getresolution(prvm_prog_t *prog) } else if(nr == -1) { - vid_mode_t *m = VID_GetDesktopMode(); - if (m) - { - PRVM_G_VECTOR(OFS_RETURN)[0] = m->width; - PRVM_G_VECTOR(OFS_RETURN)[1] = m->height; - PRVM_G_VECTOR(OFS_RETURN)[2] = m->pixelheight_num / (prvm_vec_t) m->pixelheight_denom; - } - else - { - PRVM_G_VECTOR(OFS_RETURN)[0] = 0; - PRVM_G_VECTOR(OFS_RETURN)[1] = 0; - PRVM_G_VECTOR(OFS_RETURN)[2] = 0; - } + vid_mode_t m = VID_GetDesktopMode(); + PRVM_G_VECTOR(OFS_RETURN)[0] = m.width; + PRVM_G_VECTOR(OFS_RETURN)[1] = m.height; + PRVM_G_VECTOR(OFS_RETURN)[2] = m.pixelheight_num / (prvm_vec_t) m.pixelheight_denom; } else { diff --git a/sys.h b/sys.h index f6cd4647..fc47cdba 100644 --- a/sys.h +++ b/sys.h @@ -243,7 +243,7 @@ char *Sys_ConsoleInput (void); void Sys_Sleep(int microseconds); /// Perform Key_Event () callbacks until the input que is empty -void Sys_SendKeyEvents (void); +void Sys_SDL_HandleEvents(void); char *Sys_GetClipboardData (void); diff --git a/vid.h b/vid.h index 8f1977bc..5981d976 100644 --- a/vid.h +++ b/vid.h @@ -116,10 +116,10 @@ vid_joystate_t; extern vid_joystate_t vid_joystate; -extern struct cvar_s joy_index; -extern struct cvar_s joy_enable; -extern struct cvar_s joy_detected; -extern struct cvar_s joy_active; +extern cvar_t joy_index; +extern cvar_t joy_enable; +extern cvar_t joy_detected; +extern cvar_t joy_active; float VID_JoyState_GetAxis(const vid_joystate_t *joystate, int axis, float sensitivity, float deadzone); void VID_ApplyJoyState(vid_joystate_t *joystate); @@ -134,50 +134,50 @@ extern qbool vid_hidden; extern qbool vid_activewindow; extern qbool vid_supportrefreshrate; -extern struct cvar_s vid_fullscreen; -extern struct cvar_s vid_borderless; -extern struct cvar_s vid_width; -extern struct cvar_s vid_height; -extern struct cvar_s vid_bitsperpixel; -extern struct cvar_s vid_samples; -extern struct cvar_s vid_refreshrate; -extern struct cvar_s vid_userefreshrate; -extern struct cvar_s vid_touchscreen_density; -extern struct cvar_s vid_touchscreen_xdpi; -extern struct cvar_s vid_touchscreen_ydpi; -extern struct cvar_s vid_vsync; -extern struct cvar_s vid_mouse; -extern struct cvar_s vid_mouse_clickthrough; -extern struct cvar_s vid_grabkeyboard; -extern struct cvar_s vid_touchscreen; -extern struct cvar_s vid_touchscreen_showkeyboard; -extern struct cvar_s vid_touchscreen_supportshowkeyboard; -extern struct cvar_s vid_stick_mouse; -extern struct cvar_s vid_resizable; -extern struct cvar_s vid_desktopfullscreen; +extern cvar_t vid_fullscreen; +extern cvar_t vid_borderless; +extern cvar_t vid_width; +extern cvar_t vid_height; +extern cvar_t vid_bitsperpixel; +extern cvar_t vid_samples; +extern cvar_t vid_refreshrate; +extern cvar_t vid_userefreshrate; +extern cvar_t vid_touchscreen_density; +extern cvar_t vid_touchscreen_xdpi; +extern cvar_t vid_touchscreen_ydpi; +extern cvar_t vid_vsync; +extern cvar_t vid_mouse; +extern cvar_t vid_mouse_clickthrough; +extern cvar_t vid_grabkeyboard; +extern cvar_t vid_touchscreen; +extern cvar_t vid_touchscreen_showkeyboard; +extern cvar_t vid_touchscreen_supportshowkeyboard; +extern cvar_t vid_stick_mouse; +extern cvar_t vid_resizable; +extern cvar_t vid_desktopfullscreen; #ifdef WIN32 -extern struct cvar_s vid_ignore_taskbar; +extern cvar_t vid_ignore_taskbar; #endif -extern struct cvar_s vid_minwidth; -extern struct cvar_s vid_minheight; -extern struct cvar_s vid_sRGB; -extern struct cvar_s vid_sRGB_fallback; - -extern struct cvar_s gl_finish; - -extern struct cvar_s v_gamma; -extern struct cvar_s v_contrast; -extern struct cvar_s v_brightness; -extern struct cvar_s v_color_enable; -extern struct cvar_s v_color_black_r; -extern struct cvar_s v_color_black_g; -extern struct cvar_s v_color_black_b; -extern struct cvar_s v_color_grey_r; -extern struct cvar_s v_color_grey_g; -extern struct cvar_s v_color_grey_b; -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 vid_minwidth; +extern cvar_t vid_minheight; +extern cvar_t vid_sRGB; +extern cvar_t vid_sRGB_fallback; + +extern cvar_t gl_finish; + +extern cvar_t v_gamma; +extern cvar_t v_contrast; +extern cvar_t v_brightness; +extern cvar_t v_color_enable; +extern cvar_t v_color_black_r; +extern cvar_t v_color_black_g; +extern cvar_t v_color_black_b; +extern cvar_t v_color_grey_r; +extern cvar_t v_color_grey_g; +extern cvar_t v_color_grey_b; +extern cvar_t v_color_white_r; +extern cvar_t v_color_white_g; +extern cvar_t v_color_white_b; extern cvar_t gl_info_vendor; extern cvar_t gl_info_renderer; @@ -246,7 +246,7 @@ typedef struct int pixelheight_num, pixelheight_denom; } vid_mode_t; -vid_mode_t *VID_GetDesktopMode(void); +vid_mode_t VID_GetDesktopMode(void); size_t VID_ListModes(vid_mode_t *modes, size_t maxcount); size_t VID_SortModes(vid_mode_t *modes, size_t count, qbool usebpp, qbool userefreshrate, qbool useaspect); void VID_Soft_SharedSetup(void); diff --git a/vid_null.c b/vid_null.c index 39459ee7..5b2d869c 100644 --- a/vid_null.c +++ b/vid_null.c @@ -76,7 +76,7 @@ void *GL_GetProcAddress(const char *name) return NULL; } -void Sys_SendKeyEvents(void) +void Sys_SDL_HandleEvents(void) { } @@ -88,11 +88,6 @@ void IN_Move(void) { } -vid_mode_t *VID_GetDesktopMode(void) -{ - return NULL; -} - size_t VID_ListModes(vid_mode_t *modes, size_t maxcount) { return 0; diff --git a/vid_sdl.c b/vid_sdl.c index 065c4607..8a7a326a 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -82,12 +82,9 @@ static cvar_t *steelstorm_showing_mousecursor = NULL; // detect but do not creat static int win_half_width = 50; static int win_half_height = 50; -static int video_bpp; static SDL_GLContext context; static SDL_Window *window; -static int window_flags; -static vid_mode_t desktop_mode; // Input handling @@ -1059,9 +1056,7 @@ static keynum_t buttonremap[] = }; //#define DEBUGSDLEVENTS - -// SDL2 -void Sys_SendKeyEvents( void ) +void Sys_SDL_HandleEvents(void) { static qbool sound_active = true; int keycode; @@ -1325,8 +1320,6 @@ qbool GL_ExtensionSupported(const char *name) return SDL_GL_ExtensionSupported(name); } -static qbool vid_sdl_initjoysticksystem = false; - void VID_Init (void) { #ifndef __IPHONEOS__ @@ -1345,8 +1338,7 @@ void VID_Init (void) if (SDL_Init(SDL_INIT_VIDEO) < 0) Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError()); - vid_sdl_initjoysticksystem = SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0; - if (!vid_sdl_initjoysticksystem) + if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) Con_Printf(CON_ERROR "Failed to init SDL joystick subsystem: %s\n", SDL_GetError()); } @@ -1515,9 +1507,9 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) { if (vid_desktopfullscreen.integer) { - vid_mode_t *m = VID_GetDesktopMode(); - mode->width = m->width; - mode->height = m->height; + vid_mode_t m = VID_GetDesktopMode(); + mode->width = m.width; + mode->height = m.height; windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } else @@ -1577,8 +1569,6 @@ static qbool VID_InitModeGL(viddef_mode_t *mode) SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, (gl_debug.integer > 0 ? SDL_GL_CONTEXT_DEBUG_FLAG : 0)); - video_bpp = mode->bitsperpixel; - window_flags = windowflags; window = SDL_CreateWindow(gamename, xPos, yPos, mode->width, mode->height, windowflags); if (window == NULL) { @@ -1699,11 +1689,13 @@ void VID_Finish (void) } } -vid_mode_t *VID_GetDesktopMode(void) +vid_mode_t VID_GetDesktopMode(void) { SDL_DisplayMode mode; int bpp; Uint32 rmask, gmask, bmask, amask; + vid_mode_t desktop_mode; + SDL_GetDesktopDisplayMode(0, &mode); SDL_PixelFormatEnumToMasks(mode.format, &bpp, &rmask, &gmask, &bmask, &amask); desktop_mode.width = mode.w; @@ -1715,7 +1707,7 @@ vid_mode_t *VID_GetDesktopMode(void) // TODO check whether this actually works, or whether we do still need // a read-window-size-after-entering-desktop-fullscreen hack for // multiscreen setups. - return &desktop_mode; + return desktop_mode; } size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)