From 4756c44155202cdb60e2d4eb31994614c569f366 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Tue, 27 Aug 2024 13:04:00 -0400 Subject: [PATCH 1/7] PCX_Decode warning demoted to "developer only" "(Texture.pcx) file has possible size issues" will only appear when `developer 1`. It might get annoying on properly working mods. --- src/client/cl_image.c | 2 +- src/client/refresh/files/pcx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/cl_image.c b/src/client/cl_image.c index c6dc1289..576886d7 100644 --- a/src/client/cl_image.c +++ b/src/client/cl_image.c @@ -368,7 +368,7 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett if (image_issues) { - Com_Printf("%s: %s file has possible size issues.\n", __func__, name); + Com_DPrintf("%s: %s file has possible size issues.\n", __func__, name); } } diff --git a/src/client/refresh/files/pcx.c b/src/client/refresh/files/pcx.c index d5c7257c..a6eda390 100644 --- a/src/client/refresh/files/pcx.c +++ b/src/client/refresh/files/pcx.c @@ -444,7 +444,7 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett if (image_issues) { - R_Printf(PRINT_ALL, "%s: %s file has possible size issues.\n", + R_Printf(PRINT_DEVELOPER, "%s: %s file has possible size issues.\n", __func__, name); } } From 68973b6ae728869c1ef5f65f291ee4855faedd3f Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Tue, 27 Aug 2024 13:05:44 -0400 Subject: [PATCH 2/7] Flick Stick fixed duration to 0.1 seconds Formerly, there were "6 frames" with a precalculated change factor on each frame. This allowed to use Flick Stick exclusively on vsync 60 Hz screens only (6 * 16.6 ms = 100 ms). By using any other refresh rate, or just disabling vsync, these 6 frames could take any time, normally much less than the intended 100 ms. Now delta time is used to calculate the angle change on each frame displayed, so the entire flick duration remains at 100 ms, independent of refresh rate. --- src/client/input/sdl2.c | 36 +++++++++++++++++++++++------------- src/client/input/sdl3.c | 36 +++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c index 050c8ae2..10be4ae4 100644 --- a/src/client/input/sdl2.c +++ b/src/client/input/sdl2.c @@ -198,9 +198,10 @@ static unsigned short int updates_countdown = 30; static updates_countdown_reasons countdown_reason = REASON_CONTROLLERINIT; // Flick Stick -#define FLICK_TIME 6 // number of frames it takes for a flick to execute +#define FLICK_TIME 100 // time it takes for a flick to execute, in ms static float target_angle; // angle to end up facing at the end of a flick -static unsigned short int flick_progress = FLICK_TIME; +static float flick_progress = 1.0f; // from 0.0 to 1.0 +static int started_flick; // time of flick start // Flick Stick's rotation input samples to smooth out #define MAX_SMOOTH_SAMPLES 8 @@ -1163,7 +1164,7 @@ IN_FlickStick(thumbstick_t stick, float axial_deadzone) if (IN_StickMagnitude(stick) > Q_min(joy_flick_threshold->value, 1.0f)) // flick! { // Make snap-to-axis only if player wasn't already flicking - if (!is_flicking || flick_progress < FLICK_TIME) + if (!is_flicking || flick_progress < 1.0f) { processed = IN_SlopedAxialDeadzone(stick, axial_deadzone); } @@ -1174,7 +1175,8 @@ IN_FlickStick(thumbstick_t stick, float axial_deadzone) { // Flicking begins now, with a new target is_flicking = true; - flick_progress = 0; + flick_progress = 0.0f; + started_flick = cls.realtime; target_angle = stick_angle; IN_ResetSmoothSamples(); } @@ -1212,12 +1214,6 @@ IN_Move(usercmd_t *cmd) // Factor used to transform from SDL joystick input ([-32768, 32767]) to [-1, 1] range static const float normalize_sdl_axis = 1.0f / 32768.0f; - // Flick Stick's factors to change to the target angle with a feeling of "ease out" - static const float rotation_factor[FLICK_TIME] = - { - 0.305555556f, 0.249999999f, 0.194444445f, 0.138888889f, 0.083333333f, 0.027777778f - }; - static float old_mouse_x; static float old_mouse_y; static float joystick_yaw, joystick_pitch; @@ -1422,10 +1418,24 @@ IN_Move(usercmd_t *cmd) } // Flick Stick: flick in progress, changing the yaw angle to the target progressively - if (flick_progress < FLICK_TIME) + if (flick_progress < 1.0f) { - cl.viewangles[YAW] += target_angle * rotation_factor[flick_progress]; - flick_progress++; + float old = flick_progress; + float new = (float)(cls.realtime - started_flick) / FLICK_TIME; + + if (new > 1.0f) new = 1.0f; + flick_progress = new; + + // "Ease out" warp processing for both old and new progress + // http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0 + old = 1.0f - old; + old *= old; + old = 1.0f - old; + new = 1.0f - new; + new *= new; + new = 1.0f - new; + + cl.viewangles[YAW] += (new - old) * target_angle; } } diff --git a/src/client/input/sdl3.c b/src/client/input/sdl3.c index 40e778c0..1c72ab0e 100644 --- a/src/client/input/sdl3.c +++ b/src/client/input/sdl3.c @@ -188,9 +188,10 @@ static unsigned short int updates_countdown = 30; static updates_countdown_reasons countdown_reason = REASON_CONTROLLERINIT; // Flick Stick -#define FLICK_TIME 6 // number of frames it takes for a flick to execute +#define FLICK_TIME 100 // time it takes for a flick to execute, in ms static float target_angle; // angle to end up facing at the end of a flick -static unsigned short int flick_progress = FLICK_TIME; +static float flick_progress = 1.0f; // from 0.0 to 1.0 +static int started_flick; // time of flick start // Flick Stick's rotation input samples to smooth out #define MAX_SMOOTH_SAMPLES 8 @@ -1148,7 +1149,7 @@ IN_FlickStick(thumbstick_t stick, float axial_deadzone) if (IN_StickMagnitude(stick) > Q_min(joy_flick_threshold->value, 1.0f)) // flick! { // Make snap-to-axis only if player wasn't already flicking - if (!is_flicking || flick_progress < FLICK_TIME) + if (!is_flicking || flick_progress < 1.0f) { processed = IN_SlopedAxialDeadzone(stick, axial_deadzone); } @@ -1159,7 +1160,8 @@ IN_FlickStick(thumbstick_t stick, float axial_deadzone) { // Flicking begins now, with a new target is_flicking = true; - flick_progress = 0; + flick_progress = 0.0f; + started_flick = cls.realtime; target_angle = stick_angle; IN_ResetSmoothSamples(); } @@ -1197,12 +1199,6 @@ IN_Move(usercmd_t *cmd) // Factor used to transform from SDL joystick input ([-32768, 32767]) to [-1, 1] range static const float normalize_sdl_axis = 1.0f / 32768.0f; - // Flick Stick's factors to change to the target angle with a feeling of "ease out" - static const float rotation_factor[FLICK_TIME] = - { - 0.305555556f, 0.249999999f, 0.194444445f, 0.138888889f, 0.083333333f, 0.027777778f - }; - static float old_mouse_x; static float old_mouse_y; static float joystick_yaw, joystick_pitch; @@ -1407,10 +1403,24 @@ IN_Move(usercmd_t *cmd) } // Flick Stick: flick in progress, changing the yaw angle to the target progressively - if (flick_progress < FLICK_TIME) + if (flick_progress < 1.0f) { - cl.viewangles[YAW] += target_angle * rotation_factor[flick_progress]; - flick_progress++; + float old = flick_progress; + float new = (float)(cls.realtime - started_flick) / FLICK_TIME; + + if (new > 1.0f) new = 1.0f; + flick_progress = new; + + // "Ease out" warp processing for both old and new progress + // http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0 + old = 1.0f - old; + old *= old; + old = 1.0f - old; + new = 1.0f - new; + new *= new; + new = 1.0f - new; + + cl.viewangles[YAW] += (new - old) * target_angle; } } From 15f9d35d3996e80669fc8d5bcb8f3eb508b1f7aa Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Tue, 27 Aug 2024 13:10:25 -0400 Subject: [PATCH 3/7] Default button for 'Esc' in gamepad is now Start --- doc/040_cvarlist.md | 11 +++++------ src/client/input/sdl2.c | 10 +++++----- src/client/input/sdl3.c | 10 +++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index 595ad2c5..1eebcdc1 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -570,12 +570,11 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` `1`, which enables gamepad usage; `0` disables its detection at startup. Can only be set from command line. -* **in_sdlbackbutton**: Defines which button is used in the gamepad or - joystick as the `Esc` key, to access the main menu and 'cancel' / - 'go back' on its options. Default is `0`, which corresponds to the - Back/Select/Minus button. Set to `1` to use Start/Menu/Plus, and to - `2` to use the Guide/Home/PS button. Requires a game restart - (or controller replug) when changed. +* **in_sdlbackbutton**: Defines which button is used in the gamepad as + the `Esc` key, to pull the main menu and 'cancel' / 'go back' on its + options. Valid values are `0` = Back / Select / Minus, `1` = Start / + Menu / Plus (default), or `2` = Guide / Home / PS. Requires a game + restart, or gamepad replug, when changed. * **joy_layout**: Allows to select the stick layout of the gamepad. - `0`: *Default*, left stick moves, right aims diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c index 10be4ae4..3caf22d2 100644 --- a/src/client/input/sdl2.c +++ b/src/client/input/sdl2.c @@ -78,7 +78,7 @@ typedef enum // IN_Update() called at the beginning of a frame to the // actual movement functions called at a later time. static float mouse_x, mouse_y; -static unsigned char sdl_back_button = SDL_CONTROLLER_BUTTON_BACK; +static unsigned char sdl_back_button = SDL_CONTROLLER_BUTTON_START; static int joystick_left_x, joystick_left_y, joystick_right_x, joystick_right_y; static float gyro_yaw, gyro_pitch; static qboolean mlooking; @@ -2067,19 +2067,19 @@ IN_Controller_Init(qboolean notify_user) SDL_Joystick *joystick = NULL; SDL_bool is_controller = SDL_FALSE; - cvar = Cvar_Get("in_sdlbackbutton", "0", CVAR_ARCHIVE); + cvar = Cvar_Get("in_sdlbackbutton", "1", CVAR_ARCHIVE); if (cvar) { switch ((int)cvar->value) { - case 1: - sdl_back_button = SDL_CONTROLLER_BUTTON_START; + case 0: + sdl_back_button = SDL_CONTROLLER_BUTTON_BACK; break; case 2: sdl_back_button = SDL_CONTROLLER_BUTTON_GUIDE; break; default: - sdl_back_button = SDL_CONTROLLER_BUTTON_BACK; + sdl_back_button = SDL_CONTROLLER_BUTTON_START; } } diff --git a/src/client/input/sdl3.c b/src/client/input/sdl3.c index 1c72ab0e..49c259d2 100644 --- a/src/client/input/sdl3.c +++ b/src/client/input/sdl3.c @@ -81,7 +81,7 @@ typedef enum // IN_Update() called at the beginning of a frame to the // actual movement functions called at a later time. static float mouse_x, mouse_y; -static unsigned char sdl_back_button = SDL_GAMEPAD_BUTTON_BACK; +static unsigned char sdl_back_button = SDL_GAMEPAD_BUTTON_START; static int joystick_left_x, joystick_left_y, joystick_right_x, joystick_right_y; static float gyro_yaw, gyro_pitch; static qboolean mlooking; @@ -2053,19 +2053,19 @@ IN_Controller_Init(qboolean notify_user) SDL_Joystick *joystick = NULL; SDL_bool is_controller = SDL_FALSE; - cvar = Cvar_Get("in_sdlbackbutton", "0", CVAR_ARCHIVE); + cvar = Cvar_Get("in_sdlbackbutton", "1", CVAR_ARCHIVE); if (cvar) { switch ((int)cvar->value) { - case 1: - sdl_back_button = SDL_GAMEPAD_BUTTON_START; + case 0: + sdl_back_button = SDL_GAMEPAD_BUTTON_BACK; break; case 2: sdl_back_button = SDL_GAMEPAD_BUTTON_GUIDE; break; default: - sdl_back_button = SDL_GAMEPAD_BUTTON_BACK; + sdl_back_button = SDL_GAMEPAD_BUTTON_START; } } From f83959616834d1b104cfba4f9a7aeb8651552487 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Tue, 27 Aug 2024 13:13:24 -0400 Subject: [PATCH 4/7] SDL3 nomenclature: "game controller" to "gamepad" Changes are mostly visual; many elements are still referred as "controller" in backend, to maintain parity with SDL2. --- src/client/input/sdl2.c | 6 +----- src/client/input/sdl3.c | 28 ++++++++++++---------------- src/client/menu/menu.c | 2 +- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c index 3caf22d2..3d4a8ab5 100644 --- a/src/client/input/sdl2.c +++ b/src/client/input/sdl2.c @@ -868,11 +868,7 @@ IN_Update(void) break; case SDL_CONTROLLERDEVICEREMOVED: - if (!controller) - { - break; - } - if (event.cdevice.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))) { + if (controller && event.cdevice.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))) { Cvar_SetValue("paused", 1); IN_Controller_Shutdown(true); IN_Controller_Init(false); diff --git a/src/client/input/sdl3.c b/src/client/input/sdl3.c index 49c259d2..f26ea56a 100644 --- a/src/client/input/sdl3.c +++ b/src/client/input/sdl3.c @@ -176,9 +176,9 @@ static cvar_t *gyro_calibration_x; static cvar_t *gyro_calibration_y; static cvar_t *gyro_calibration_z; static unsigned int num_samples; -#define NATIVE_SDL_GYRO // uses SDL_CONTROLLERSENSORUPDATE to read gyro +#define NATIVE_SDL_GYRO // uses SDL_EVENT_GAMEPAD_SENSOR_UPDATE to read gyro -// To ignore SDL_JOYDEVICEADDED at game init. Allows for hot plugging of game controller afterwards. +// To ignore SDL_EVENT_JOYSTICK_ADDED at game init. Allows for hot plugging of gamepad afterwards. static qboolean first_init = true; // Countdown of calls to IN_Update(), needed for controller init and gyro calibration @@ -859,11 +859,7 @@ IN_Update(void) break; case SDL_EVENT_GAMEPAD_REMOVED : - if (!controller) - { - break; - } - if (event.gdevice.which == SDL_GetJoystickInstanceID(SDL_GetGamepadJoystick(controller))) { + if (controller && event.gdevice.which == SDL_GetJoystickInstanceID(SDL_GetGamepadJoystick(controller))) { Cvar_SetValue("paused", 1); IN_Controller_Shutdown(true); IN_Controller_Init(false); @@ -920,7 +916,7 @@ IN_Update(void) sys_frame_time = Sys_Milliseconds(); // Hot plugging delay handling, to not be "overwhelmed" because some controllers - // present themselves as two different devices, triggering SDL_JOYDEVICEADDED + // present themselves as two different devices, triggering SDL_EVENT_JOYSTICK_ADDED // too many times. They could trigger it even at game initialization. // Also used to keep time of the 'controller gyro calibration' pause. if (updates_countdown) @@ -952,7 +948,7 @@ IN_Update(void) #else if (!num_samples[0] || !num_samples[1] || !num_samples[2]) { - Com_Printf("Calibration failed, please retry inside a level after having moved your controller a little.\n"); + Com_Printf("Calibration failed, please retry inside a level after having moved your gamepad a little.\n"); } else { @@ -2077,7 +2073,7 @@ IN_Controller_Init(qboolean notify_user) if (notify_user) { - Com_Printf("- Game Controller init attempt -\n"); + Com_Printf("- Gamepad init attempt -\n"); } if (!SDL_WasInit(SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC)) @@ -2092,7 +2088,7 @@ IN_Controller_Init(qboolean notify_user) if (SDL_Init(SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC) == -1) { - Com_Printf ("Couldn't init SDL Game Controller: %s.\n", SDL_GetError()); + Com_Printf ("Couldn't init SDL Gamepad: %s.\n", SDL_GetError()); return; } } @@ -2186,7 +2182,7 @@ IN_Controller_Init(qboolean notify_user) SDL_GetJoystickGUIDString(guid, joystick_guid, 64); - Com_Printf ("To use joystick as game controller, provide its config by either:\n" + Com_Printf ("To identify joystick as Gamepad, provide its config by either:\n" " * Putting 'gamecontrollerdb.txt' file in your game directory.\n" " * Or setting SDL_GAMECONTROLLERCONFIG environment variable. E.g.:\n"); Com_Printf ("SDL_GAMECONTROLLERCONFIG='%s,%s,leftx:a0,lefty:a1,rightx:a2,righty:a3,back:b1,...'\n", joystick_guid, joystick_name); @@ -2200,12 +2196,12 @@ IN_Controller_Init(qboolean notify_user) controller = SDL_OpenGamepad(joysticks[i]); if (!controller) { - Com_Printf("SDL Controller error: %s.\n", SDL_GetError()); + Com_Printf("SDL Gamepad error: %s.\n", SDL_GetError()); continue; // try next joystick } show_gamepad = true; - Com_Printf("Enabled as Game Controller, settings:\n%s\n", + Com_Printf("Enabled as Gamepad, settings:\n%s\n", SDL_GetGamepadMapping(controller)); #ifdef NATIVE_SDL_GYRO @@ -2254,7 +2250,7 @@ IN_Controller_Init(qboolean notify_user) } else { - Com_Printf("Controller doesn't support rumble.\n"); + Com_Printf("Gamepad doesn't support rumble.\n"); } #ifdef NATIVE_SDL_GYRO // "native" exits when finding a single working controller @@ -2370,7 +2366,7 @@ IN_Controller_Shutdown(qboolean notify_user) { if (notify_user) { - Com_Printf("- Game Controller disconnected -\n"); + Com_Printf("- Gamepad disconnected -\n"); } IN_Haptic_Shutdown(); diff --git a/src/client/menu/menu.c b/src/client/menu/menu.c index 8f3df66e..55d9a4e3 100644 --- a/src/client/menu/menu.c +++ b/src/client/menu/menu.c @@ -1955,7 +1955,7 @@ Gyro_MenuInit(void) s_calibrating_text[0].generic.type = MTYPE_SEPARATOR; s_calibrating_text[0].generic.x = 48 * scale + 32; s_calibrating_text[0].generic.y = (y += 20); - s_calibrating_text[0].generic.name = "place the controller on a flat,"; + s_calibrating_text[0].generic.name = "place the gamepad on a flat,"; s_calibrating_text[1].generic.type = MTYPE_SEPARATOR; s_calibrating_text[1].generic.x = 48 * scale + 32; From 13deb72b16b762204b1b1b0331d0fe5201e09989 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Thu, 29 Aug 2024 15:44:34 -0400 Subject: [PATCH 5/7] Flick Stick refactor Removed redundant calculations --- src/client/input/sdl2.c | 29 +++++++++++++++-------------- src/client/input/sdl3.c | 29 +++++++++++++++-------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/client/input/sdl2.c b/src/client/input/sdl2.c index 3d4a8ab5..bc733ddb 100644 --- a/src/client/input/sdl2.c +++ b/src/client/input/sdl2.c @@ -1416,22 +1416,23 @@ IN_Move(usercmd_t *cmd) // Flick Stick: flick in progress, changing the yaw angle to the target progressively if (flick_progress < 1.0f) { - float old = flick_progress; - float new = (float)(cls.realtime - started_flick) / FLICK_TIME; + float cur_progress = (float)(cls.realtime - started_flick) / FLICK_TIME; - if (new > 1.0f) new = 1.0f; - flick_progress = new; + if (cur_progress > 1.0f) + { + cur_progress = 1.0f; + } + else + { + // "Ease out" warp processing: f(x)=1-(1-x)^2 , 0 <= x <= 1 + // http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0 + cur_progress = 1.0f - cur_progress; + cur_progress *= cur_progress; + cur_progress = 1.0f - cur_progress; + } - // "Ease out" warp processing for both old and new progress - // http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0 - old = 1.0f - old; - old *= old; - old = 1.0f - old; - new = 1.0f - new; - new *= new; - new = 1.0f - new; - - cl.viewangles[YAW] += (new - old) * target_angle; + cl.viewangles[YAW] += (cur_progress - flick_progress) * target_angle; + flick_progress = cur_progress; } } diff --git a/src/client/input/sdl3.c b/src/client/input/sdl3.c index f26ea56a..e719b975 100644 --- a/src/client/input/sdl3.c +++ b/src/client/input/sdl3.c @@ -1401,22 +1401,23 @@ IN_Move(usercmd_t *cmd) // Flick Stick: flick in progress, changing the yaw angle to the target progressively if (flick_progress < 1.0f) { - float old = flick_progress; - float new = (float)(cls.realtime - started_flick) / FLICK_TIME; + float cur_progress = (float)(cls.realtime - started_flick) / FLICK_TIME; - if (new > 1.0f) new = 1.0f; - flick_progress = new; + if (cur_progress > 1.0f) + { + cur_progress = 1.0f; + } + else + { + // "Ease out" warp processing: f(x)=1-(1-x)^2 , 0 <= x <= 1 + // http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0 + cur_progress = 1.0f - cur_progress; + cur_progress *= cur_progress; + cur_progress = 1.0f - cur_progress; + } - // "Ease out" warp processing for both old and new progress - // http://gyrowiki.jibbsmart.com/blog:good-gyro-controls-part-2:the-flick-stick#toc0 - old = 1.0f - old; - old *= old; - old = 1.0f - old; - new = 1.0f - new; - new *= new; - new = 1.0f - new; - - cl.viewangles[YAW] += (new - old) * target_angle; + cl.viewangles[YAW] += (cur_progress - flick_progress) * target_angle; + flick_progress = cur_progress; } } From b00e925d479e137023873ff6d5f08cdcf38dbc08 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Fri, 30 Aug 2024 00:05:28 -0400 Subject: [PATCH 6/7] Refactored obtaining the renderer used ...in videomenu code. Now it allows to use switch statements, to avoid the execution of paths not meant for certain renderers. --- src/client/menu/videomenu.c | 398 ++++++++++++++++++++---------------- 1 file changed, 223 insertions(+), 175 deletions(-) diff --git a/src/client/menu/videomenu.c b/src/client/menu/videomenu.c index cc82203d..602a5885 100644 --- a/src/client/menu/videomenu.c +++ b/src/client/menu/videomenu.c @@ -79,6 +79,16 @@ static menuaction_s s_apply_action; // gl1, gl3, gles1, gles3, gl4, vk, soft #define MAXRENDERERS 7 +typedef enum +{ + ref_custom, + ref_gl1, // encompasses gl1 and gles1 + ref_gl3, // encompasses gl3 and gles3 + ref_gl4, + ref_vk, + ref_soft +} renderer_type; + typedef struct { const char *boxstr; @@ -195,36 +205,64 @@ ResetDefaults(void *unused) #define CUSTOM_MODE_NAME "[Custom ]" #define AUTO_MODE_NAME "[Auto ]" +static renderer_type +CurrentRendererByCvar(void) +{ + if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0) + { + return ref_gl3; + } + if (Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0) + { + return ref_gl1; + } + if (Q_stricmp(vid_renderer->string, "soft") == 0) + { + return ref_soft; + } + if (Q_stricmp(vid_renderer->string, "gl4") == 0) + { + return ref_gl4; + } + if (Q_stricmp(vid_renderer->string, "vk") == 0) + { + return ref_vk; + } + return ref_custom; +} + static void ApplyFilter(void* unused) { - if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 || - Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0) + switch (CurrentRendererByCvar()) { - if (s_filter_list.curvalue == 0) - { - Cvar_Set("gl_texturemode", "GL_NEAREST"); - } - else if (s_filter_list.curvalue == 1) - { - Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST"); - } - else if (s_filter_list.curvalue == 2) - { - Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR"); - } - } - - if (Q_stricmp(vid_renderer->string, "soft") == 0) - { - if (s_filter_list.curvalue == 0) - { - Cvar_Set("sw_texture_filtering", "0"); - } - else if (s_filter_list.curvalue == 1) - { - Cvar_Set("sw_texture_filtering", "1"); - } + case ref_gl3: + case ref_gl1: + if (s_filter_list.curvalue == 0) + { + Cvar_Set("gl_texturemode", "GL_NEAREST"); + } + else if (s_filter_list.curvalue == 1) + { + Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST"); + } + else if (s_filter_list.curvalue == 2) + { + Cvar_Set("gl_texturemode", "GL_LINEAR_MIPMAP_LINEAR"); + } + break; + case ref_soft: + if (s_filter_list.curvalue == 0) + { + Cvar_Set("sw_texture_filtering", "0"); + } + else if (s_filter_list.curvalue == 1) + { + Cvar_Set("sw_texture_filtering", "1"); + } + break; + default: + break; // avoid compiler warning } } @@ -412,6 +450,8 @@ VID_MenuInit(void) 0 }; + const renderer_type current_renderer = CurrentRendererByCvar(); + static const char *uiscale_names[] = { "auto", "1x", @@ -569,106 +609,111 @@ VID_MenuInit(void) s_fov_slider.slidestep = 1; s_fov_slider.printformat = "%.0f"; - if (strcmp(vid_renderer->string, "gl3") == 0 || strcmp(vid_renderer->string, "gles3") == 0) + switch (current_renderer) { - s_gl3_intensity_slider.generic.type = MTYPE_SLIDER; - s_gl3_intensity_slider.generic.name = "color intensity"; - s_gl3_intensity_slider.generic.x = 0; - s_gl3_intensity_slider.generic.y = (y += 10); - s_gl3_intensity_slider.cvar = "gl3_intensity"; - s_gl3_intensity_slider.minvalue = 0.1f; - s_gl3_intensity_slider.maxvalue = 5.0f; + case ref_gl3: + s_gl3_intensity_slider.generic.type = MTYPE_SLIDER; + s_gl3_intensity_slider.generic.name = "color intensity"; + s_gl3_intensity_slider.generic.x = 0; + s_gl3_intensity_slider.generic.y = (y += 10); + s_gl3_intensity_slider.cvar = "gl3_intensity"; + s_gl3_intensity_slider.minvalue = 0.1f; + s_gl3_intensity_slider.maxvalue = 5.0f; - s_gl3_overbrightbits_slider.generic.type = MTYPE_SLIDER; - s_gl3_overbrightbits_slider.generic.name = "overbrights"; - s_gl3_overbrightbits_slider.generic.x = 0; - s_gl3_overbrightbits_slider.generic.y = (y += 10); - s_gl3_overbrightbits_slider.cvar = "gl3_overbrightbits"; - s_gl3_overbrightbits_slider.minvalue = 0.1f; - s_gl3_overbrightbits_slider.maxvalue = 5.0f; + s_gl3_overbrightbits_slider.generic.type = MTYPE_SLIDER; + s_gl3_overbrightbits_slider.generic.name = "overbrights"; + s_gl3_overbrightbits_slider.generic.x = 0; + s_gl3_overbrightbits_slider.generic.y = (y += 10); + s_gl3_overbrightbits_slider.cvar = "gl3_overbrightbits"; + s_gl3_overbrightbits_slider.minvalue = 0.1f; + s_gl3_overbrightbits_slider.maxvalue = 5.0f; - gl3_colorlight = Cvar_Get("gl3_colorlight", "1", CVAR_ARCHIVE); - s_gl3_colorlight_list.generic.type = MTYPE_SPINCONTROL; - s_gl3_colorlight_list.generic.name = "color light"; - s_gl3_colorlight_list.generic.x = 0; - s_gl3_colorlight_list.generic.y = (y += 10); - s_gl3_colorlight_list.itemnames = yesno_names; - s_gl3_colorlight_list.curvalue = (gl3_colorlight->value != 0); - } - if (strcmp(vid_renderer->string, "gl4") == 0) - { - s_gl4_intensity_slider.generic.type = MTYPE_SLIDER; - s_gl4_intensity_slider.generic.name = "color intensity"; - s_gl4_intensity_slider.generic.x = 0; - s_gl4_intensity_slider.generic.y = (y += 10); - s_gl4_intensity_slider.cvar = "gl4_intensity"; - s_gl4_intensity_slider.minvalue = 0.1f; - s_gl4_intensity_slider.maxvalue = 5.0f; + gl3_colorlight = Cvar_Get("gl3_colorlight", "1", CVAR_ARCHIVE); + s_gl3_colorlight_list.generic.type = MTYPE_SPINCONTROL; + s_gl3_colorlight_list.generic.name = "color light"; + s_gl3_colorlight_list.generic.x = 0; + s_gl3_colorlight_list.generic.y = (y += 10); + s_gl3_colorlight_list.itemnames = yesno_names; + s_gl3_colorlight_list.curvalue = (gl3_colorlight->value != 0); + break; - s_gl4_overbrightbits_slider.generic.type = MTYPE_SLIDER; - s_gl4_overbrightbits_slider.generic.name = "overbrights"; - s_gl4_overbrightbits_slider.generic.x = 0; - s_gl4_overbrightbits_slider.generic.y = (y += 10); - s_gl4_overbrightbits_slider.cvar = "gl4_overbrightbits"; - s_gl4_overbrightbits_slider.minvalue = 0.1f; - s_gl4_overbrightbits_slider.maxvalue = 5.0f; + case ref_gl4: + s_gl4_intensity_slider.generic.type = MTYPE_SLIDER; + s_gl4_intensity_slider.generic.name = "color intensity"; + s_gl4_intensity_slider.generic.x = 0; + s_gl4_intensity_slider.generic.y = (y += 10); + s_gl4_intensity_slider.cvar = "gl4_intensity"; + s_gl4_intensity_slider.minvalue = 0.1f; + s_gl4_intensity_slider.maxvalue = 5.0f; - gl4_colorlight = Cvar_Get("gl4_colorlight", "1", CVAR_ARCHIVE); - s_gl4_colorlight_list.generic.type = MTYPE_SPINCONTROL; - s_gl4_colorlight_list.generic.name = "color light"; - s_gl4_colorlight_list.generic.x = 0; - s_gl4_colorlight_list.generic.y = (y += 10); - s_gl4_colorlight_list.itemnames = yesno_names; - s_gl4_colorlight_list.curvalue = (gl4_colorlight->value != 0); - } - else if (strcmp(vid_renderer->string, "vk") == 0) - { - s_vk_intensity_slider.generic.type = MTYPE_SLIDER; - s_vk_intensity_slider.generic.name = "color intensity"; - s_vk_intensity_slider.generic.x = 0; - s_vk_intensity_slider.generic.y = (y += 10); - s_vk_intensity_slider.cvar = "vk_intensity"; - s_vk_intensity_slider.minvalue = 0; - s_vk_intensity_slider.maxvalue = 5; - s_vk_intensity_slider.slidestep = 1; - s_vk_intensity_slider.printformat = "%.0f"; + s_gl4_overbrightbits_slider.generic.type = MTYPE_SLIDER; + s_gl4_overbrightbits_slider.generic.name = "overbrights"; + s_gl4_overbrightbits_slider.generic.x = 0; + s_gl4_overbrightbits_slider.generic.y = (y += 10); + s_gl4_overbrightbits_slider.cvar = "gl4_overbrightbits"; + s_gl4_overbrightbits_slider.minvalue = 0.1f; + s_gl4_overbrightbits_slider.maxvalue = 5.0f; - s_vk_overbrightbits_slider.generic.type = MTYPE_SLIDER; - s_vk_overbrightbits_slider.generic.name = "overbrights"; - s_vk_overbrightbits_slider.generic.x = 0; - s_vk_overbrightbits_slider.generic.y = (y += 10); - s_vk_overbrightbits_slider.cvar = "vk_overbrightbits"; - s_vk_overbrightbits_slider.minvalue = 0.1f; - s_vk_overbrightbits_slider.maxvalue = 5.0f; + gl4_colorlight = Cvar_Get("gl4_colorlight", "1", CVAR_ARCHIVE); + s_gl4_colorlight_list.generic.type = MTYPE_SPINCONTROL; + s_gl4_colorlight_list.generic.name = "color light"; + s_gl4_colorlight_list.generic.x = 0; + s_gl4_colorlight_list.generic.y = (y += 10); + s_gl4_colorlight_list.itemnames = yesno_names; + s_gl4_colorlight_list.curvalue = (gl4_colorlight->value != 0); + break; - vk_dynamic = Cvar_Get("vk_dynamic", "1", CVAR_ARCHIVE); - s_vk_dynamic_list.generic.type = MTYPE_SPINCONTROL; - s_vk_dynamic_list.generic.name = "dynamic light"; - s_vk_dynamic_list.generic.x = 0; - s_vk_dynamic_list.generic.y = (y += 10); - s_vk_dynamic_list.itemnames = yesno_names; - s_vk_dynamic_list.curvalue = (vk_dynamic->value != 0); - } - else - { - gl3_colorlight = NULL; - s_gl1_intensity_slider.generic.type = MTYPE_SLIDER; - s_gl1_intensity_slider.generic.name = "color intensity"; - s_gl1_intensity_slider.generic.x = 0; - s_gl1_intensity_slider.generic.y = (y += 10); - s_gl1_intensity_slider.cvar = "gl1_intensity"; - s_gl1_intensity_slider.minvalue = 1.0f; - s_gl1_intensity_slider.maxvalue = 10.0f; + case ref_vk: + s_vk_intensity_slider.generic.type = MTYPE_SLIDER; + s_vk_intensity_slider.generic.name = "color intensity"; + s_vk_intensity_slider.generic.x = 0; + s_vk_intensity_slider.generic.y = (y += 10); + s_vk_intensity_slider.cvar = "vk_intensity"; + s_vk_intensity_slider.minvalue = 0; + s_vk_intensity_slider.maxvalue = 5; + s_vk_intensity_slider.slidestep = 1; + s_vk_intensity_slider.printformat = "%.0f"; - s_gl1_overbrightbits_slider.generic.type = MTYPE_SLIDER; - s_gl1_overbrightbits_slider.generic.name = "overbrights"; - s_gl1_overbrightbits_slider.generic.x = 0; - s_gl1_overbrightbits_slider.generic.y = (y += 10); - s_gl1_overbrightbits_slider.cvar = "gl1_overbrightbits"; - s_gl1_overbrightbits_slider.minvalue = 0; - s_gl1_overbrightbits_slider.maxvalue = 2; - s_gl1_overbrightbits_slider.slidestep = 1; - s_gl1_overbrightbits_slider.printformat = "%.0f"; + s_vk_overbrightbits_slider.generic.type = MTYPE_SLIDER; + s_vk_overbrightbits_slider.generic.name = "overbrights"; + s_vk_overbrightbits_slider.generic.x = 0; + s_vk_overbrightbits_slider.generic.y = (y += 10); + s_vk_overbrightbits_slider.cvar = "vk_overbrightbits"; + s_vk_overbrightbits_slider.minvalue = 0.1f; + s_vk_overbrightbits_slider.maxvalue = 5.0f; + + vk_dynamic = Cvar_Get("vk_dynamic", "1", CVAR_ARCHIVE); + s_vk_dynamic_list.generic.type = MTYPE_SPINCONTROL; + s_vk_dynamic_list.generic.name = "dynamic light"; + s_vk_dynamic_list.generic.x = 0; + s_vk_dynamic_list.generic.y = (y += 10); + s_vk_dynamic_list.itemnames = yesno_names; + s_vk_dynamic_list.curvalue = (vk_dynamic->value != 0); + break; + + case ref_gl1: + gl3_colorlight = NULL; + s_gl1_intensity_slider.generic.type = MTYPE_SLIDER; + s_gl1_intensity_slider.generic.name = "color intensity"; + s_gl1_intensity_slider.generic.x = 0; + s_gl1_intensity_slider.generic.y = (y += 10); + s_gl1_intensity_slider.cvar = "gl1_intensity"; + s_gl1_intensity_slider.minvalue = 1.0f; + s_gl1_intensity_slider.maxvalue = 10.0f; + + s_gl1_overbrightbits_slider.generic.type = MTYPE_SLIDER; + s_gl1_overbrightbits_slider.generic.name = "overbrights"; + s_gl1_overbrightbits_slider.generic.x = 0; + s_gl1_overbrightbits_slider.generic.y = (y += 10); + s_gl1_overbrightbits_slider.cvar = "gl1_overbrightbits"; + s_gl1_overbrightbits_slider.minvalue = 0; + s_gl1_overbrightbits_slider.maxvalue = 2; + s_gl1_overbrightbits_slider.slidestep = 1; + s_gl1_overbrightbits_slider.printformat = "%.0f"; + break; + + default: + break; } s_uiscale_list.generic.type = MTYPE_SPINCONTROL; @@ -747,46 +792,50 @@ VID_MenuInit(void) s_filter_list.generic.name = "texture filter"; s_filter_list.curvalue = 0; s_filter_list.generic.callback = ApplyFilter; + s_filter_list.generic.x = 0; const char* filter = NULL; int mode = 0; - - if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 || - Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0) - { - s_filter_list.generic.x = 0; - s_filter_list.generic.y = (y += 10); - s_filter_list.itemnames = filter_names; - - filter = Cvar_VariableString("gl_texturemode"); - mode = 3; - if (Q_stricmp(filter, "GL_NEAREST") == 0) - { - mode = 0; - } - else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_NEAREST") == 0) - { - mode = 1; - } - else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_LINEAR") == 0) - { - mode = 2; - } - } - else if (Q_stricmp(vid_renderer->string, "soft") == 0) + switch (current_renderer) { - s_filter_list.generic.x = 0; - s_filter_list.generic.y = (y += 10); - s_filter_list.itemnames = onoff_names; + case ref_gl3: + case ref_gl1: + s_filter_list.generic.y = (y += 10); + s_filter_list.itemnames = filter_names; - filter = Cvar_VariableString("sw_texture_filtering"); - mode = 0; + filter = Cvar_VariableString("gl_texturemode"); + mode = 3; - if (Q_stricmp(filter, "1") == 0) - { - mode = 1; - } + if (Q_stricmp(filter, "GL_NEAREST") == 0) + { + mode = 0; + } + else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_NEAREST") == 0) + { + mode = 1; + } + else if (Q_stricmp(filter, "GL_LINEAR_MIPMAP_LINEAR") == 0) + { + mode = 2; + } + break; + + case ref_soft: + s_filter_list.generic.y = (y += 10); + s_filter_list.itemnames = onoff_names; + + filter = Cvar_VariableString("sw_texture_filtering"); + mode = 0; + + if (Q_stricmp(filter, "1") == 0) + { + mode = 1; + } + break; + + default: + break; } s_filter_list.curvalue = mode; @@ -814,37 +863,36 @@ VID_MenuInit(void) Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider); Menu_AddItem(&s_opengl_menu, (void *)&s_fov_slider); - if (strcmp(vid_renderer->string, "gl3") == 0 || strcmp(vid_renderer->string, "gles3") == 0) + switch (current_renderer) { - Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_intensity_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_overbrightbits_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_colorlight_list); - } - else if (strcmp(vid_renderer->string, "gl4") == 0) - { - Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_intensity_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_overbrightbits_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_colorlight_list); - } - else if (strcmp(vid_renderer->string, "vk") == 0) - { - Menu_AddItem(&s_opengl_menu, (void *)&s_vk_intensity_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_vk_overbrightbits_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_vk_dynamic_list); - } - else if (strcmp(vid_renderer->string, "gl1") == 0 || strcmp(vid_renderer->string, "gles1") == 0) - { - Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_intensity_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_overbrightbits_slider); + case ref_gl3: + Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_intensity_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_overbrightbits_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_gl3_colorlight_list); + break; + case ref_gl4: + Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_intensity_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_overbrightbits_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_gl4_colorlight_list); + break; + case ref_vk: + Menu_AddItem(&s_opengl_menu, (void *)&s_vk_intensity_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_vk_overbrightbits_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_vk_dynamic_list); + break; + case ref_gl1: + Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_intensity_slider); + Menu_AddItem(&s_opengl_menu, (void *)&s_gl1_overbrightbits_slider); + break; + default: + break; } Menu_AddItem(&s_opengl_menu, (void *)&s_uiscale_list); Menu_AddItem(&s_opengl_menu, (void *)&s_fs_box); Menu_AddItem(&s_opengl_menu, (void *)&s_vsync_list); Menu_AddItem(&s_opengl_menu, (void *)&s_af_list); Menu_AddItem(&s_opengl_menu, (void *)&s_msaa_list); - if (Q_stricmp(vid_renderer->string, "gl3") == 0 || Q_stricmp(vid_renderer->string, "gles3") == 0 || - Q_stricmp(vid_renderer->string, "gl1") == 0 || Q_stricmp(vid_renderer->string, "gles1") == 0 || - Q_stricmp(vid_renderer->string, "soft") == 0) + if (current_renderer == ref_gl3 || current_renderer == ref_gl1 || current_renderer == ref_soft) { Menu_AddItem(&s_opengl_menu, (void *)&s_filter_list); } From d90dc649ecaff316895147f4b60fecedd5557a93 Mon Sep 17 00:00:00 2001 From: Jaime Moreira Date: Sun, 1 Sep 2024 19:21:48 -0400 Subject: [PATCH 7/7] Revert "PCX_Decode warning demoted to 'dev only'" This reverts commit 4756c44155202cdb60e2d4eb31994614c569f366. --- src/client/cl_image.c | 2 +- src/client/refresh/files/pcx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/cl_image.c b/src/client/cl_image.c index 576886d7..c6dc1289 100644 --- a/src/client/cl_image.c +++ b/src/client/cl_image.c @@ -368,7 +368,7 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett if (image_issues) { - Com_DPrintf("%s: %s file has possible size issues.\n", __func__, name); + Com_Printf("%s: %s file has possible size issues.\n", __func__, name); } } diff --git a/src/client/refresh/files/pcx.c b/src/client/refresh/files/pcx.c index a6eda390..d5c7257c 100644 --- a/src/client/refresh/files/pcx.c +++ b/src/client/refresh/files/pcx.c @@ -444,7 +444,7 @@ PCX_Decode(const char *name, const byte *raw, int len, byte **pic, byte **palett if (image_issues) { - R_Printf(PRINT_DEVELOPER, "%s: %s file has possible size issues.\n", + R_Printf(PRINT_ALL, "%s: %s file has possible size issues.\n", __func__, name); } }