Skip to content

Commit

Permalink
Fix SDL3 include
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Oct 5, 2024
1 parent 7810d46 commit e947fec
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion src_c/SDL_gfx/SDL_gfxPrimitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ LGPL (c) A. Schiffler
#define M_PI 3.1415926535897932384626433832795
#endif

#include "SDL.h"
#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
#undef PYPY_VERSION
#endif

#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

#if SDL_VERSION_ATLEAST(3, 0, 0)
#define PG_ShowCursor SDL_ShowCursor
Expand Down
4 changes: 4 additions & 0 deletions src_c/palette.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
#ifndef PALETTE_H
#define PALETTE_H

#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#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
Expand Down
4 changes: 4 additions & 0 deletions src_c/pgcompat.c
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif
4 changes: 4 additions & 0 deletions src_c/pgcompat_rect.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef PGCOMPAT_RECT_H
#define PGCOMPAT_RECT_H

#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

/* SDL 2.0.22 provides some utility functions for FRects */
#if !(SDL_VERSION_ATLEAST(2, 0, 22))
Expand Down
5 changes: 5 additions & 0 deletions src_c/scale2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
surprised with this code!
*/

#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

Expand Down
6 changes: 5 additions & 1 deletion src_c/scrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
#include <limits.h>
#include <stdio.h>

#include "SDL.h"
#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

#include "SDL_syswm.h"

Expand Down
9 changes: 7 additions & 2 deletions src_c/scrap_sdl2.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "SDL.h"
#include "SDL_clipboard.h"
#ifdef PG_SDL3
#include <SDL3/SDL.h>
#include <SDL3/SDL_clipboard.h>
#else
#include <SDL.h>
#include <SDL_clipboard.h>
#endif

#define PYGAME_SCRAP_FREE_STRING 1

Expand Down
5 changes: 5 additions & 0 deletions src_c/surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
#undef _POSIX_C_SOURCE
#endif

#ifdef PG_SDL3
#include <SDL3/SDL.h>
#else
#include <SDL.h>
#endif

#include "pygame.h"

/* Blend modes */
Expand Down

0 comments on commit e947fec

Please sign in to comment.