diff --git a/src/client/refresh/gl4/gl4_main.c b/src/client/refresh/gl4/gl4_main.c index 49c8c1e5..118f94ab 100644 --- a/src/client/refresh/gl4/gl4_main.c +++ b/src/client/refresh/gl4/gl4_main.c @@ -1954,6 +1954,7 @@ GetRefAPI(refimport_t imp) ri = imp; re.api_version = API_VERSION; + re.framework_version = GL4_GetSDLVersion(); re.Init = GL4_Init; re.Shutdown = GL4_Shutdown; diff --git a/src/client/refresh/gl4/gl4_sdl.c b/src/client/refresh/gl4/gl4_sdl.c index 7a8677d9..ada0dc6a 100644 --- a/src/client/refresh/gl4/gl4_sdl.c +++ b/src/client/refresh/gl4/gl4_sdl.c @@ -29,7 +29,11 @@ #include "header/local.h" +#ifdef USE_SDL3 +#include +#else #include +#endif static SDL_Window* window = NULL; static SDL_GLContext context = NULL; @@ -149,7 +153,20 @@ void GL4_SetVsync(void) } } +#ifdef USE_SDL3 + int vsyncState; + if (SDL_GL_GetSwapInterval(&vsyncState) != 0) + { + R_Printf(PRINT_ALL, "Failed to get vsync state, assuming vsync inactive.\n"); + vsyncActive = false; + } + else + { + vsyncActive = vsyncState ? true : false; + } +#else vsyncActive = SDL_GL_GetSwapInterval() != 0; +#endif } /* @@ -323,7 +340,7 @@ int GL4_InitContext(void* win) GL4_SetVsync(); // Load GL pointrs through GLAD and check context. - if( !gladLoadGLLoader(SDL_GL_GetProcAddress)) + if( !gladLoadGLLoader((void *)SDL_GL_GetProcAddress)) { R_Printf(PRINT_ALL, "GL4_InitContext(): ERROR: loading OpenGL function pointers failed!\n"); @@ -361,7 +378,11 @@ int GL4_InitContext(void* win) #if SDL_VERSION_ATLEAST(2, 26, 0) // Figure out if we are high dpi aware. int flags = SDL_GetWindowFlags(win); +#ifdef USE_SDL3 + IsHighDPIaware = (flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) ? true : false; +#else IsHighDPIaware = (flags & SDL_WINDOW_ALLOW_HIGHDPI) ? true : false; +#endif #endif return true; @@ -372,7 +393,11 @@ int GL4_InitContext(void* win) */ void GL4_GetDrawableSize(int* width, int* height) { +#ifdef USE_SDL3 + SDL_GetWindowSizeInPixels(window, width, height); +#else SDL_GL_GetDrawableSize(window, width, height); +#endif } /* @@ -389,3 +414,21 @@ void GL4_ShutdownContext() } } } + +/* + * Returns the SDL major version. Implemented + * here to not polute gl3_main.c with the SDL + * headers. + */ +int GL4_GetSDLVersion() +{ +#ifdef USE_SDL3 + SDL_Version ver; +#else + SDL_version ver; +#endif + + SDL_VERSION(&ver); + + return ver.major; +} diff --git a/src/client/refresh/gl4/header/local.h b/src/client/refresh/gl4/header/local.h index 466f5eb0..ceb75502 100644 --- a/src/client/refresh/gl4/header/local.h +++ b/src/client/refresh/gl4/header/local.h @@ -383,6 +383,7 @@ extern qboolean GL4_IsVsyncActive(void); extern void GL4_EndFrame(void); extern void GL4_SetVsync(void); extern void GL4_ShutdownContext(void); +extern int GL4_GetSDLVersion(void); // gl4_misc.c extern void GL4_InitParticleTexture(void);