Skip to content

Commit

Permalink
Rework SDL_INIT_TIMER for SDL3
Browse files Browse the repository at this point in the history
No longer exists in SDL3, so simple compat is to mock it out to a macro that is zero in SDL3.
  • Loading branch information
Starbuck5 committed Oct 31, 2024
1 parent c5781dc commit 4d6a8e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ PG_UnlockMutex(SDL_mutex *mutex)
#define PG_FIND_VNUM_MINOR(ver) SDL_VERSIONNUM_MINOR(ver)
#define PG_FIND_VNUM_MICRO(ver) SDL_VERSIONNUM_MICRO(ver)

#define PG_INIT_TIMER 0

#else /* ~SDL_VERSION_ATLEAST(3, 0, 0)*/
#define PG_ShowCursor() SDL_ShowCursor(SDL_ENABLE)
#define PG_HideCursor() SDL_ShowCursor(SDL_DISABLE)
Expand Down Expand Up @@ -180,6 +182,8 @@ PG_UnlockMutex(SDL_mutex *mutex)
#define PG_FIND_VNUM_MINOR(ver) ver.minor
#define PG_FIND_VNUM_MICRO(ver) ver.patch

#define PG_INIT_TIMER SDL_INIT_TIMER

#if SDL_VERSION_ATLEAST(2, 0, 14)
#define PG_SurfaceHasRLE SDL_HasSurfaceRLE
#else
Expand Down
4 changes: 2 additions & 2 deletions src_c/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ pg_init(PyObject *self, PyObject *_null)

/*nice to initialize timer, so startup time will reflec pg_init() time*/
#if defined(WITH_THREAD) && !defined(MS_WIN32) && defined(SDL_INIT_EVENTTHREAD)
pg_sdl_was_init = SDL_Init(SDL_INIT_EVENTTHREAD | SDL_INIT_TIMER |
pg_sdl_was_init = SDL_Init(SDL_INIT_EVENTTHREAD | PG_INIT_TIMER |
PG_INIT_NOPARACHUTE) == 0;
#else
pg_sdl_was_init = SDL_Init(SDL_INIT_TIMER | PG_INIT_NOPARACHUTE) == 0;
pg_sdl_was_init = SDL_Init(PG_INIT_TIMER | PG_INIT_NOPARACHUTE) == 0;
#endif

pg_env_blend_alpha_SDL2 = SDL_getenv("PYGAME_BLEND_ALPHA_SDL2");
Expand Down

0 comments on commit 4d6a8e3

Please sign in to comment.