diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index 76101066..fb0cdaf1 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -26,12 +26,11 @@ If you have questions concerning this license or the applicable additional terms =========================================================================== */ -#ifdef D3_SDL3 - #include +#include "sys/sys_sdl.h" + +#if SDL_VERSION_ATLEAST(3, 0, 0) // DG: compat with SDL2 #define SDL_setenv SDL_setenv_unsafe -#else // SDL1.2 or SDL2 - #include #endif #include "sys/platform.h" diff --git a/neo/framework/Dhewm3SettingsMenu.cpp b/neo/framework/Dhewm3SettingsMenu.cpp index 27aa963b..189f2f63 100644 --- a/neo/framework/Dhewm3SettingsMenu.cpp +++ b/neo/framework/Dhewm3SettingsMenu.cpp @@ -2,11 +2,7 @@ #include // std::sort - TODO: replace with something custom.. -#ifdef D3_SDL3 - #include -#else // SDL1.2 or SDL2 - #include -#endif +#include "sys/sys_sdl.h" #define IMGUI_DEFINE_MATH_OPERATORS diff --git a/neo/sys/events.cpp b/neo/sys/events.cpp index 184e9535..9f2d97be 100644 --- a/neo/sys/events.cpp +++ b/neo/sys/events.cpp @@ -26,13 +26,7 @@ If you have questions concerning this license or the applicable additional terms =========================================================================== */ -#ifdef D3_SDL3 - // HACK: I don't want SDL.h to drag in SDL_oldnames.h to avoid all the warnings about redefined definitions - #define SDL_oldnames_h_ - #include -#else // SDL1.2 or SDL2 - #include -#endif +#include "sys/sys_sdl.h" #include "sys/platform.h" #include "idlib/containers/List.h" diff --git a/neo/sys/glimp.cpp b/neo/sys/glimp.cpp index 4bd3f52b..78c88df3 100644 --- a/neo/sys/glimp.cpp +++ b/neo/sys/glimp.cpp @@ -26,14 +26,14 @@ If you have questions concerning this license or the applicable additional terms =========================================================================== */ -#ifdef D3_SDL3 - #include +#include "sys/sys_sdl.h" + +#if SDL_VERSION_ATLEAST(3, 0, 0) // backwards-compat with SDL2 #define SDL_WINDOW_ALLOW_HIGHDPI SDL_WINDOW_HIGH_PIXEL_DENSITY #define SDL_GL_DeleteContext SDL_GL_DestroyContext typedef SDL_WindowFlags My_SDL_WindowFlags; #else // SDL1.2 or SDL2 - #include // for compat with SDL3 - unfortunately SDL2 also has a SDL_WindowFlags type, but it's an enum typedef Uint32 My_SDL_WindowFlags; #endif diff --git a/neo/sys/posix/posix_main.cpp b/neo/sys/posix/posix_main.cpp index 276a0bb9..8b8f73cc 100644 --- a/neo/sys/posix/posix_main.cpp +++ b/neo/sys/posix/posix_main.cpp @@ -50,11 +50,7 @@ If you have questions concerning this license or the applicable additional terms #include "sys/posix/posix_public.h" // SDL.h for clipboard: -#ifdef D3_SDL3 - #include -#else // SDL1.2 or SDL2 - #include -#endif +#include "sys/sys_sdl.h" #define COMMAND_HISTORY 64 diff --git a/neo/sys/sys_imgui.cpp b/neo/sys/sys_imgui.cpp index 435d181d..82448b96 100644 --- a/neo/sys/sys_imgui.cpp +++ b/neo/sys/sys_imgui.cpp @@ -1,8 +1,9 @@ #define IMGUI_DEFINE_MATH_OPERATORS -#ifdef D3_SDL3 - #include +#include "sys_sdl.h" + +#if SDL_VERSION_ATLEAST(3, 0, 0) // compat with SDL2 #define SDL_TEXTINPUT SDL_EVENT_TEXT_INPUT #define SDL_CONTROLLERAXISMOTION SDL_EVENT_GAMEPAD_AXIS_MOTION @@ -11,8 +12,6 @@ #define SDL_MOUSEMOTION SDL_EVENT_MOUSE_MOTION #define SDL_MOUSEWHEEL SDL_EVENT_MOUSE_WHEEL #define SDL_KEYDOWN SDL_EVENT_KEY_DOWN -#else // SDL2 - #include #endif diff --git a/neo/sys/sys_sdl.h b/neo/sys/sys_sdl.h new file mode 100644 index 00000000..c0041dc1 --- /dev/null +++ b/neo/sys/sys_sdl.h @@ -0,0 +1,14 @@ +// just a wrapper for #include to support SDL1.2, SDL2 and SDL3 + +#ifndef NEO_SYS_SYS_SDL_H_ +#define NEO_SYS_SYS_SDL_H_ + +#ifdef D3_SDL3 + // HACK: I don't want SDL.h to drag in SDL_oldnames.h to avoid all the warnings about redefined definitions + #define SDL_oldnames_h_ + #include +#else // SDL1.2 or SDL2 + #include +#endif + +#endif /* NEO_SYS_SYS_SDL_H_ */ diff --git a/neo/sys/threads.cpp b/neo/sys/threads.cpp index 99eb9e8c..d2a07cfb 100644 --- a/neo/sys/threads.cpp +++ b/neo/sys/threads.cpp @@ -26,10 +26,9 @@ If you have questions concerning this license or the applicable additional terms =========================================================================== */ -#ifdef D3_SDL3 - #define SDL_oldnames_h_ // HACK: I don't want SDL.h to drag in SDL_oldnames.h to avoid all the warnings about redefined definitions - #include -#else // SDL1.2 or SDL2 +#include "sys/sys_sdl.h" + +#if 0 // TODO: was there a reason not to include full SDL.h? #include #include #include diff --git a/neo/tools/debugger/DebuggerServer.h b/neo/tools/debugger/DebuggerServer.h index 8d62a5cd..c9ea69db 100644 --- a/neo/tools/debugger/DebuggerServer.h +++ b/neo/tools/debugger/DebuggerServer.h @@ -28,15 +28,7 @@ If you have questions concerning this license or the applicable additional terms #ifndef DEBUGGERSERVER_H_ #define DEBUGGERSERVER_H_ -#ifdef D3_SDL3 - #define SDL_oldnames_h_ // HACK: I don't want SDL.h to drag in SDL_oldnames.h to avoid all the warnings about redefined definitions - #include - // backwards-compat with SDL <= 2 - #define SDL_mutex SDL_Mutex - #define SDL_cond SDL_Condition -#else // SDL1.2 or SDL2 - #include -#endif +#include "sys/sys_sdl.h" #include "sys/platform.h" #include "idlib/Str.h" @@ -44,6 +36,12 @@ If you have questions concerning this license or the applicable additional terms #include "DebuggerBreakpoint.h" #include "framework/Game.h" +#if SDL_VERSION_ATLEAST(3, 0, 0) + // backwards-compat with SDL <= 2 + #define SDL_mutex SDL_Mutex + #define SDL_cond SDL_Condition +#endif + class function_t; typedef struct prstack_s prstack_t;