diff --git a/meson.build b/meson.build index f5916d698c..7d882abf65 100644 --- a/meson.build +++ b/meson.build @@ -84,6 +84,10 @@ sdl_mixer = '@0@_mixer'.format(sdl) sdl_ttf = '@0@_ttf'.format(sdl) sdl_image = '@0@_image'.format(sdl) +if sdl_ver == 3 + add_global_arguments('-DPG_SDL3=1', language: 'c') +endif + pg_inc_dirs = [] pg_lib_dirs = [] if plat == 'win' and host_machine.cpu_family().startswith('x86') diff --git a/src_c/SDL_gfx/SDL_gfxPrimitives.h b/src_c/SDL_gfx/SDL_gfxPrimitives.h index ec5dc17c3b..4f75913023 100644 --- a/src_c/SDL_gfx/SDL_gfxPrimitives.h +++ b/src_c/SDL_gfx/SDL_gfxPrimitives.h @@ -14,7 +14,11 @@ LGPL (c) A. Schiffler #define M_PI 3.1415926535897932384626433832795 #endif -#include "SDL.h" +#ifdef PG_SDL3 +#include +#else +#include +#endif /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus diff --git a/src_c/_pygame.h b/src_c/_pygame.h index e87986d776..d330a08290 100644 --- a/src_c/_pygame.h +++ b/src_c/_pygame.h @@ -41,7 +41,11 @@ #undef PYPY_VERSION #endif +#ifdef PG_SDL3 +#include +#else #include +#endif #if SDL_VERSION_ATLEAST(3, 0, 0) #define PG_ShowCursor SDL_ShowCursor diff --git a/src_c/palette.h b/src_c/palette.h index 702840a624..699a40edb4 100644 --- a/src_c/palette.h +++ b/src_c/palette.h @@ -23,7 +23,11 @@ #ifndef PALETTE_H #define PALETTE_H +#ifdef PG_SDL3 +#include +#else #include +#endif /* SDL 2 does not assign a default palette color scheme to a new 8 bit * surface. Instead, the palette is set all white. This defines the SDL 1.2 diff --git a/src_c/pgcompat.c b/src_c/pgcompat.c index 5d64d2e6fd..178102e186 100644 --- a/src_c/pgcompat.c +++ b/src_c/pgcompat.c @@ -1 +1,5 @@ +#ifdef PG_SDL3 +#include +#else #include +#endif diff --git a/src_c/pgcompat_rect.h b/src_c/pgcompat_rect.h index 643059dfcb..5bba69dd21 100644 --- a/src_c/pgcompat_rect.h +++ b/src_c/pgcompat_rect.h @@ -1,7 +1,11 @@ #ifndef PGCOMPAT_RECT_H #define PGCOMPAT_RECT_H +#ifdef PG_SDL3 +#include +#else #include +#endif /* SDL 2.0.22 provides some utility functions for FRects */ #if !(SDL_VERSION_ATLEAST(2, 0, 22)) diff --git a/src_c/scale2x.c b/src_c/scale2x.c index 61a9beffa5..9249a05a78 100644 --- a/src_c/scale2x.c +++ b/src_c/scale2x.c @@ -30,7 +30,12 @@ surprised with this code! */ +#ifdef PG_SDL3 +#include +#else #include +#endif + #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/src_c/scrap.c b/src_c/scrap.c index b34cb6b06e..ef580e7a99 100644 --- a/src_c/scrap.c +++ b/src_c/scrap.c @@ -23,7 +23,11 @@ #include #include -#include "SDL.h" +#ifdef PG_SDL3 +#include +#else +#include +#endif #include "SDL_syswm.h" diff --git a/src_c/scrap_sdl2.c b/src_c/scrap_sdl2.c index 9c2121c105..5de1f4cdbc 100644 --- a/src_c/scrap_sdl2.c +++ b/src_c/scrap_sdl2.c @@ -1,5 +1,10 @@ -#include "SDL.h" -#include "SDL_clipboard.h" +#ifdef PG_SDL3 +#include +#include +#else +#include +#include +#endif #define PYGAME_SCRAP_FREE_STRING 1 diff --git a/src_c/surface.h b/src_c/surface.h index 3ae05eb408..4009579d1d 100644 --- a/src_c/surface.h +++ b/src_c/surface.h @@ -29,7 +29,12 @@ #undef _POSIX_C_SOURCE #endif +#ifdef PG_SDL3 +#include +#else #include +#endif + #include "pygame.h" /* Blend modes */