Bump to SDL3 gitrev f6fc5e2

This commit is contained in:
erysdren 2024-08-30 14:13:53 -05:00 committed by Yamagi
parent 2c212ae0b2
commit 219b1b93fb
5 changed files with 67 additions and 30 deletions

View file

@ -2006,7 +2006,7 @@ Controller_Rumble(const char *name, vec3_t source, qboolean from_player,
// Com_Printf("%-29s: vol %5u - %4u ms - dp %.3f l %5.0f h %5.0f\n",
// name, effect_volume, duration, dist_prop, low_freq, hi_freq);
if (SDL_RumbleGamepad(controller, low_freq, hi_freq, duration) == -1)
if (!SDL_RumbleGamepad(controller, low_freq, hi_freq, duration))
{
if (!joystick_haptic)
{
@ -2092,7 +2092,7 @@ IN_Controller_Init(qboolean notify_user)
SDL_SetHint( SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1" );
#endif
if (SDL_Init(SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC) == -1)
if (!SDL_Init(SDL_INIT_GAMEPAD | SDL_INIT_HAPTIC))
{
Com_Printf ("Couldn't init SDL Gamepad: %s.\n", SDL_GetError());
return;

View file

@ -126,7 +126,11 @@ int RI_PrepareForWindow(void)
{
msaa_samples = gl_msaa_samples->value;
#ifdef USE_SDL3
if (!SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1))
#else
if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) < 0)
#endif
{
R_Printf(PRINT_ALL, "MSAA is unsupported: %s\n", SDL_GetError());
@ -135,7 +139,11 @@ int RI_PrepareForWindow(void)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
#ifdef USE_SDL3
else if (!SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples))
#else
else if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples) < 0)
#endif
{
R_Printf(PRINT_ALL, "MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
@ -172,7 +180,11 @@ void RI_SetVsync(void)
vsync = -1;
}
#ifdef USE_SDL3
if (!SDL_GL_SetSwapInterval(vsync))
#else
if (SDL_GL_SetSwapInterval(vsync) == -1)
#endif
{
if (vsync == -1)
{
@ -185,7 +197,7 @@ void RI_SetVsync(void)
#ifdef USE_SDL3
int vsyncState;
if (SDL_GL_GetSwapInterval(&vsyncState) != 0)
if (!SDL_GL_GetSwapInterval(&vsyncState))
{
R_Printf(PRINT_ALL, "Failed to get vsync state, assuming vsync inactive.\n");
vsyncActive = false;
@ -296,7 +308,11 @@ int RI_InitContext(void* win)
if (gl_state.stencil)
{
#ifdef USE_SDL3
if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) || stencil_bits < 8)
#else
if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) < 0 || stencil_bits < 8)
#endif
{
gl_state.stencil = false;
}

View file

@ -155,7 +155,11 @@ void GL3_SetVsync(void)
vsync = -1;
}
#ifdef USE_SDL3
if (!SDL_GL_SetSwapInterval(vsync))
#else
if (SDL_GL_SetSwapInterval(vsync) == -1)
#endif
{
if (vsync == -1)
{
@ -168,7 +172,7 @@ void GL3_SetVsync(void)
#ifdef USE_SDL3
int vsyncState;
if (SDL_GL_GetSwapInterval(&vsyncState) != 0)
if (!SDL_GL_GetSwapInterval(&vsyncState))
{
R_Printf(PRINT_ALL, "Failed to get vsync state, assuming vsync inactive.\n");
vsyncActive = false;
@ -204,7 +208,11 @@ int GL3_PrepareForWindow(void)
while (1)
{
#ifdef USE_SDL3
if (!SDL_GL_LoadLibrary(libgl))
#else
if (SDL_GL_LoadLibrary(libgl) < 0)
#endif
{
if (libgl == NULL)
{
@ -236,7 +244,11 @@ int GL3_PrepareForWindow(void)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
#ifdef USE_SDL3
if (SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8))
#else
if (SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) == 0)
#endif
{
gl3config.stencil = true;
}
@ -279,7 +291,11 @@ int GL3_PrepareForWindow(void)
{
msaa_samples = gl_msaa_samples->value;
#ifdef USE_SDL3
if (!SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1))
#else
if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1) < 0)
#endif
{
R_Printf(PRINT_ALL, "MSAA is unsupported: %s\n", SDL_GetError());
@ -288,7 +304,11 @@ int GL3_PrepareForWindow(void)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
#ifdef USE_SDL3
else if (!SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples))
#else
else if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, msaa_samples) < 0)
#endif
{
R_Printf(PRINT_ALL, "MSAA %ix is unsupported: %s\n", msaa_samples, SDL_GetError());
@ -351,7 +371,11 @@ int GL3_InitContext(void* win)
if (gl3config.stencil)
{
#ifdef USE_SDL3
if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) || stencil_bits < 8)
#else
if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) < 0 || stencil_bits < 8)
#endif
{
gl3config.stencil = false;
}

View file

@ -1362,7 +1362,11 @@ SDL_BackendInit(void)
if (!SDL_WasInit(SDL_INIT_AUDIO))
{
#ifdef USE_SDL3
if (!SDL_Init(SDL_INIT_AUDIO))
#else
if (SDL_Init(SDL_INIT_AUDIO) == -1)
#endif
{
Com_Printf ("Couldn't init SDL audio: %s.\n", SDL_GetError ());
return 0;

View file

@ -161,7 +161,7 @@ CreateSDLWindow(int flags, int fullscreen, int w, int h)
switch to it in exclusive fullscreen mode. */
SDL_DisplayMode closestMode;
if (SDL_GetClosestFullscreenDisplayMode(last_display, w, h, vid_rate->value, false, &closestMode) != 0)
if (SDL_GetClosestFullscreenDisplayMode(last_display, w, h, vid_rate->value, false, &closestMode) != SDL_TRUE)
{
Com_Printf("SDL was unable to find a mode close to %ix%i@%f\n", w, h, vid_rate->value);
@ -169,7 +169,7 @@ CreateSDLWindow(int flags, int fullscreen, int w, int h)
{
Com_Printf("Retrying with desktop refresh rate\n");
if (SDL_GetClosestFullscreenDisplayMode(last_display, w, h, vid_rate->value, false, &closestMode) == 0)
if (SDL_GetClosestFullscreenDisplayMode(last_display, w, h, vid_rate->value, false, &closestMode) == SDL_TRUE)
{
Cvar_SetValue("vid_rate", 0);
}
@ -187,26 +187,19 @@ CreateSDLWindow(int flags, int fullscreen, int w, int h)
/* TODO SDL3: Same code is in InitGraphics(), refactor into
* a function? */
if (SDL_SetWindowFullscreenMode(window, &closestMode) < 0)
if (!SDL_SetWindowFullscreenMode(window, &closestMode))
{
Com_Printf("Couldn't set closest mode: %s\n", SDL_GetError());
return false;
}
if (SDL_SetWindowFullscreen(window, true) < 0)
if (!SDL_SetWindowFullscreen(window, true))
{
Com_Printf("Couldn't switch to exclusive fullscreen: %s\n", SDL_GetError());
return false;
}
int ret = SDL_SyncWindow(window);
if (ret > 0)
{
Com_Printf("Synchronizing window state timed out\n");
return false;
}
else if (ret < 0)
if (!SDL_SyncWindow(window))
{
Com_Printf("Couldn't synchronize window state: %s\n", SDL_GetError());
return false;
@ -251,7 +244,7 @@ GetWindowSize(int* w, int* h)
return false;
}
if (SDL_GetWindowSize(window, w, h) < 0)
if (!SDL_GetWindowSize(window, w, h))
{
Com_Printf("Couldn't get window size: %s\n", SDL_GetError());
return false;
@ -411,7 +404,7 @@ GLimp_Init(void)
if (!SDL_WasInit(SDL_INIT_VIDEO))
{
if (SDL_Init(SDL_INIT_VIDEO) == -1)
if (!SDL_Init(SDL_INIT_VIDEO))
{
Com_Printf("Couldn't init SDL video: %s.\n", SDL_GetError());
@ -516,7 +509,7 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
{
if (fullscreen == FULLSCREEN_EXCLUSIVE)
{
if (SDL_GetClosestFullscreenDisplayMode(last_display, width, height, vid_rate->value, false, &closestMode) != 0)
if (SDL_GetClosestFullscreenDisplayMode(last_display, width, height, vid_rate->value, false, &closestMode) != SDL_TRUE)
{
Com_Printf("SDL was unable to find a mode close to %ix%i@%f\n", width, height, vid_rate->value);
@ -524,7 +517,7 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
{
Com_Printf("Retrying with desktop refresh rate\n");
if (SDL_GetClosestFullscreenDisplayMode(last_display, width, height, 0, false, &closestMode) == 0)
if (SDL_GetClosestFullscreenDisplayMode(last_display, width, height, 0, false, &closestMode) == SDL_TRUE)
{
Cvar_SetValue("vid_rate", 0);
}
@ -542,28 +535,21 @@ GLimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
/* closestMode = NULL; */
}
if (SDL_SetWindowFullscreenMode(window, &closestMode) < 0)
if (!SDL_SetWindowFullscreenMode(window, &closestMode))
{
Com_Printf("Couldn't set fullscreen modmode: %s\n", SDL_GetError());
Cvar_SetValue("vid_fullscreen", 0);
}
else
{
if (SDL_SetWindowFullscreen(window, true) < 0)
if (!SDL_SetWindowFullscreen(window, true))
{
Com_Printf("Couldn't switch to exclusive fullscreen: %s\n", SDL_GetError());
Cvar_SetValue("vid_fullscreen", 0);
}
else
{
int ret = SDL_SyncWindow(window);
if (ret > 0)
{
Com_Printf("Synchronizing window state timed out\n");
Cvar_SetValue("vid_fullscreen", 0);
}
else if (ret < 0)
if (!SDL_SyncWindow(window))
{
Com_Printf("Couldn't synchronize window state: %s\n", SDL_GetError());
Cvar_SetValue("vid_fullscreen", 0);
@ -781,11 +767,18 @@ GLimp_GrabInput(qboolean grab)
SDL_SetWindowMouseGrab(window, grab ? SDL_TRUE : SDL_FALSE);
}
#ifdef USE_SDL3
if(!SDL_SetWindowRelativeMouseMode(window, grab ? SDL_TRUE : SDL_FALSE))
{
Com_Printf("WARNING: Setting Relative Mousemode failed, reason: %s\n", SDL_GetError());
}
#else
if(SDL_SetWindowRelativeMouseMode(window, grab ? SDL_TRUE : SDL_FALSE) < 0)
{
Com_Printf("WARNING: Setting Relative Mousemode failed, reason: %s\n", SDL_GetError());
Com_Printf(" You should probably update to SDL 2.0.3 or newer!\n");
}
#endif
}
/*