Skip to content

Commit 464e206

Browse files
committed
Fix SDL3 include
1 parent f6162fd commit 464e206

10 files changed

+47
-4
lines changed

meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ sdl_mixer = '@0@_mixer'.format(sdl)
8484
sdl_ttf = '@0@_ttf'.format(sdl)
8585
sdl_image = '@0@_image'.format(sdl)
8686

87+
if sdl_api == 3
88+
add_global_arguments('-DPG_SDL3=1', language: 'c')
89+
endif
90+
8791
pg_inc_dirs = []
8892
pg_lib_dirs = []
8993
if plat == 'win' and host_machine.cpu_family().startswith('x86')

src_c/SDL_gfx/SDL_gfxPrimitives.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ LGPL (c) A. Schiffler
1414
#define M_PI 3.1415926535897932384626433832795
1515
#endif
1616

17-
#include "SDL.h"
17+
#ifdef PG_SDL3
18+
#include <SDL3/SDL.h>
19+
#else
20+
#include <SDL.h>
21+
#endif
1822

1923
/* Set up for C function definitions, even when using C++ */
2024
#ifdef __cplusplus

src_c/_pygame.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@
4141
#undef PYPY_VERSION
4242
#endif
4343

44+
#ifdef PG_SDL3
45+
#include <SDL3/SDL.h>
46+
#else
4447
#include <SDL.h>
48+
#endif
4549

4650
#if SDL_VERSION_ATLEAST(3, 0, 0)
4751
#define PG_ShowCursor SDL_ShowCursor

src_c/palette.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#ifndef PALETTE_H
2424
#define PALETTE_H
2525

26+
#ifdef PG_SDL3
27+
#include <SDL3/SDL.h>
28+
#else
2629
#include <SDL.h>
30+
#endif
2731

2832
/* SDL 2 does not assign a default palette color scheme to a new 8 bit
2933
* surface. Instead, the palette is set all white. This defines the SDL 1.2

src_c/pgcompat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
#ifdef PG_SDL3
2+
#include <SDL3/SDL.h>
3+
#else
14
#include <SDL.h>
5+
#endif

src_c/pgcompat_rect.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#ifndef PGCOMPAT_RECT_H
22
#define PGCOMPAT_RECT_H
33

4+
#ifdef PG_SDL3
5+
#include <SDL3/SDL.h>
6+
#else
47
#include <SDL.h>
8+
#endif
59

610
/* SDL 2.0.22 provides some utility functions for FRects */
711
#if !(SDL_VERSION_ATLEAST(2, 0, 22))

src_c/scale2x.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
surprised with this code!
3131
*/
3232

33+
#ifdef PG_SDL3
34+
#include <SDL3/SDL.h>
35+
#else
3336
#include <SDL.h>
37+
#endif
38+
3439
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
3540
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
3641

src_c/scrap.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
#include <limits.h>
2424
#include <stdio.h>
2525

26-
#include "SDL.h"
26+
#ifdef PG_SDL3
27+
#include <SDL3/SDL.h>
28+
#else
29+
#include <SDL.h>
30+
#endif
2731

2832
#include "SDL_syswm.h"
2933

src_c/scrap_sdl2.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
#include "SDL.h"
2-
#include "SDL_clipboard.h"
1+
#ifdef PG_SDL3
2+
#include <SDL3/SDL.h>
3+
#include <SDL3/SDL_clipboard.h>
4+
#else
5+
#include <SDL.h>
6+
#include <SDL_clipboard.h>
7+
#endif
38

49
#define PYGAME_SCRAP_FREE_STRING 1
510

src_c/surface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
#undef _POSIX_C_SOURCE
3030
#endif
3131

32+
#ifdef PG_SDL3
33+
#include <SDL3/SDL.h>
34+
#else
3235
#include <SDL.h>
36+
#endif
37+
3338
#include "pygame.h"
3439

3540
/* Blend modes */

0 commit comments

Comments
 (0)