Browse Source

Use SDL3-compatible SDL includes when SDL3 headers are available

Sasha Szpakowski 10 months ago
parent
commit
e986160431

+ 5 - 0
src/common/delay.cpp

@@ -20,8 +20,13 @@
 
 #include "delay.h"
 
+#if __has_include(<SDL3/SDL_timer.h>)
+#include <SDL3/SDL_timer.h>
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_timer.h>
 #include <SDL_version.h>
+#endif
 
 namespace love
 {

+ 6 - 1
src/love.cpp

@@ -22,12 +22,17 @@
 #include "common/runtime.h"
 #include "common/Variant.h"
 #include "modules/love/love.h"
+
+#if __has_include(<SDL3/SDL.h>)
+#include <SDL3/SDL.h>
+#else
 #include <SDL.h>
+#endif
 
 #ifdef LOVE_BUILD_EXE
 
 #if SDL_VERSION_ATLEAST(3, 0, 0)
-#include <SDL_main.h>
+#include <SDL3/SDL_main.h>
 #endif
 
 // Lua

+ 4 - 0
src/modules/event/sdl/Event.cpp

@@ -35,7 +35,11 @@
 
 #include <cmath>
 
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_version.h>
+#endif
 
 #if SDL_VERSION_ATLEAST(3, 0, 0)
 #include "joystick/sdl/JoystickSDL3.h"

+ 4 - 0
src/modules/event/sdl/Event.h

@@ -26,7 +26,11 @@
 #include "audio/Source.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_events.h>)
+#include <SDL3/SDL_events.h>
+#else
 #include <SDL_events.h>
+#endif
 
 namespace love
 {

+ 5 - 0
src/modules/filesystem/wrap_Filesystem.cpp

@@ -34,8 +34,13 @@
 #endif
 
 // SDL
+#if __has_include(<SDL3/SDL_loadso.h>)
+#include <SDL3/SDL_loadso.h>
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_loadso.h>
 #include <SDL_version.h>
+#endif
 
 // STL
 #include <vector>

+ 4 - 0
src/modules/graphics/opengl/OpenGL.cpp

@@ -37,7 +37,11 @@
 #include <cstdio>
 
 // For SDL_GL_GetProcAddress.
+#if __has_include(<SDL3/SDL_video.h>)
+#include <SDL3/SDL_video.h>
+#else
 #include <SDL_video.h>
+#endif
 
 #ifdef LOVE_IOS
 #include <SDL_syswm.h>

+ 5 - 0
src/modules/graphics/vulkan/Graphics.cpp

@@ -29,8 +29,13 @@
 #include "Shader.h"
 #include "Vulkan.h"
 
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#include <SDL3/SDL_vulkan.h>
+#else
 #include <SDL_version.h>
 #include <SDL_vulkan.h>
+#endif
 
 #include <algorithm>
 #include <vector>

+ 4 - 0
src/modules/joystick/sdl/Joystick.cpp

@@ -25,7 +25,11 @@
 #include "sensor/sdl/Sensor.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_version.h>
+#endif
 
 // C++
 #include <algorithm>

+ 4 - 0
src/modules/joystick/sdl/Joystick.h

@@ -26,7 +26,11 @@
 #include "common/EnumMap.h"
 
 // SDL
+#if __has_include(<SDL3/SDL.h>)
+#include <SDL3/SDL.h>
+#else
 #include <SDL.h>
+#endif
 
 #if !SDL_VERSION_ATLEAST(3, 0, 0)
 

+ 4 - 0
src/modules/joystick/sdl/JoystickModule.cpp

@@ -24,7 +24,11 @@
 #include "JoystickSDL3.h"
 
 // SDL
+#if __has_include(<SDL3/SDL.h>)
+#include <SDL3/SDL.h>
+#else
 #include <SDL.h>
+#endif
 
 // C++
 #include <sstream>

+ 5 - 1
src/modules/joystick/sdl/JoystickSDL3.cpp

@@ -25,11 +25,15 @@
 #include "sensor/sdl/Sensor.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_version.h>
+#endif
 
 #if SDL_VERSION_ATLEAST(3, 0, 0)
 
-#include <SDL_guid.h>
+#include <SDL3/SDL_guid.h>
 
 // C++
 #include <algorithm>

+ 4 - 0
src/modules/joystick/sdl/JoystickSDL3.h

@@ -27,7 +27,11 @@
 #include "common/int.h"
 
 // SDL
+#if __has_include(<SDL3/SDL.h>)
+#include <SDL3/SDL.h>
+#else
 #include <SDL.h>
+#endif
 
 #if SDL_VERSION_ATLEAST(3, 0, 0)
 

+ 4 - 0
src/modules/keyboard/sdl/Keyboard.cpp

@@ -18,7 +18,11 @@
  * 3. This notice may not be removed or altered from any source distribution.
  **/
 
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_version.h>
+#endif
 
 #include "Keyboard.h"
 #include "window/Window.h"

+ 5 - 0
src/modules/keyboard/sdl/Keyboard.h

@@ -26,8 +26,13 @@
 #include "common/EnumMap.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_keyboard.h>)
+#include <SDL3/SDL_keyboard.h>
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_keyboard.h>
 #include <SDL_version.h>
+#endif
 
 #include <map>
 

+ 4 - 0
src/modules/mouse/sdl/Cursor.cpp

@@ -22,7 +22,11 @@
 #include "Cursor.h"
 #include "common/config.h"
 
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_version.h>
+#endif
 
 namespace love
 {

+ 4 - 0
src/modules/mouse/sdl/Cursor.h

@@ -26,7 +26,11 @@
 #include "common/EnumMap.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_mouse.h>)
+#include <SDL3/SDL_mouse.h>
+#else
 #include <SDL_mouse.h>
+#endif
 
 namespace love
 {

+ 5 - 0
src/modules/mouse/sdl/Mouse.cpp

@@ -23,8 +23,13 @@
 #include "window/sdl/Window.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_mouse.h>
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_mouse.h>
 #include <SDL_version.h>
+#endif
 
 namespace love
 {

+ 5 - 0
src/modules/sensor/sdl/Sensor.cpp

@@ -22,8 +22,13 @@
 #include "Sensor.h"
 
 // SDL
+#if __has_include(<SDL3/SDL.h>)
+#include <SDL3/SDL.h>
+#include <SDL3/SDL_sensor.h>
+#else
 #include <SDL.h>
 #include <SDL_sensor.h>
+#endif
 
 namespace love
 {

+ 4 - 0
src/modules/sensor/sdl/Sensor.h

@@ -25,7 +25,11 @@
 #include "sensor/Sensor.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_sensor.h>)
+#include <SDL3/SDL_sensor.h>
+#else
 #include <SDL_sensor.h>
+#endif
 
 // std
 #include <map>

+ 7 - 0
src/modules/system/sdl/System.cpp

@@ -23,6 +23,12 @@
 #include "window/Window.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_clipboard.h>)
+#include <SDL3/SDL_clipboard.h>
+#include <SDL3/SDL_cpuinfo.h>
+#include <SDL3/SDL_version.h>
+#include <SDL3/SDL_locale.h>
+#else
 #include <SDL_clipboard.h>
 #include <SDL_cpuinfo.h>
 #include <SDL_version.h>
@@ -30,6 +36,7 @@
 #if SDL_VERSION_ATLEAST(2, 0, 14)
 #include <SDL_locale.h>
 #endif
+#endif
 
 namespace love
 {

+ 4 - 0
src/modules/system/sdl/System.h

@@ -26,7 +26,11 @@
 #include "common/EnumMap.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_power.h>)
+#include <SDL3/SDL_power.h>
+#else
 #include <SDL_power.h>
+#endif
 
 namespace love
 {

+ 4 - 0
src/modules/thread/sdl/Thread.h

@@ -26,7 +26,11 @@
 #include "threads.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_thread.h>)
+#include <SDL3/SDL_thread.h>
+#else
 #include <SDL_thread.h>
+#endif
 
 namespace love
 {

+ 6 - 0
src/modules/thread/sdl/threads.h

@@ -24,9 +24,15 @@
 #include "common/config.h"
 #include "thread/threads.h"
 
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#include <SDL3/SDL_thread.h>
+#include <SDL3/SDL_mutex.h>
+#else
 #include <SDL_version.h>
 #include <SDL_thread.h>
 #include <SDL_mutex.h>
+#endif
 
 namespace love
 {

+ 4 - 0
src/modules/touch/sdl/Touch.cpp

@@ -23,7 +23,11 @@
 #include "common/Exception.h"
 #include "Touch.h"
 
+#if __has_include(<SDL3/SDL_version.h>)
+#include <SDL3/SDL_version.h>
+#else
 #include <SDL_version.h>
+#endif
 
 // C++
 #include <algorithm>

+ 4 - 0
src/modules/touch/sdl/Touch.h

@@ -25,7 +25,11 @@
 #include "touch/Touch.h"
 
 // SDL
+#if __has_include(<SDL3/SDL_events.h>)
+#include <SDL3/SDL_events.h>
+#else
 #include <SDL_events.h>
+#endif
 
 namespace love
 {

+ 4 - 0
src/modules/window/sdl/Window.cpp

@@ -49,8 +49,12 @@
 #endif
 
 #ifdef LOVE_GRAPHICS_VULKAN
+#if __has_include(<SDL3/SDL_vulkan.h>)
+#include <SDL3/SDL_vulkan.h>
+#else
 #include <SDL_vulkan.h>
 #endif
+#endif
 
 #if defined(LOVE_WINDOWS)
 #define WIN32_LEAN_AND_MEAN

+ 4 - 0
src/modules/window/sdl/Window.h

@@ -27,7 +27,11 @@
 #include "graphics/Graphics.h"
 
 // SDL
+#if __has_include(<SDL3/SDL.h>)
+#include <SDL3/SDL.h>
+#else
 #include <SDL.h>
+#endif
 
 namespace love
 {