Skip to content

Commit

Permalink
Fix compilation errors with old SDL versions
Browse files Browse the repository at this point in the history
SDL_PixelFormatEnum has been introduced in SDL 2.0.10:
<libsdl-org/SDL@cc6a8ac>

SDL_PIXELFORMAT_BGR444 has been introduced in SDL 2.0.12:
<libsdl-org/SDL@a1c1185>

Fixes #2777 <#2777>
PR #2781 <#2781>

Reviewed-by: Yu-Chen Lin <npes87184@gmail.com>
  • Loading branch information
rom1v committed Nov 14, 2021
1 parent 65b023a commit 739ff9d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/src/icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ decode_image(const char *path) {
return result;
}

#if !SDL_VERSION_ATLEAST(2, 0, 10)
// SDL_PixelFormatEnum has been introduced in SDL 2.0.10. Use int for older SDL
// versions.
typedef int SDL_PixelFormatEnum;
#endif

static SDL_PixelFormatEnum
to_sdl_pixel_format(enum AVPixelFormat fmt) {
switch (fmt) {
Expand All @@ -172,7 +178,9 @@ to_sdl_pixel_format(enum AVPixelFormat fmt) {
case AV_PIX_FMT_BGR565BE: return SDL_PIXELFORMAT_BGR565;
case AV_PIX_FMT_BGR555BE: return SDL_PIXELFORMAT_BGR555;
case AV_PIX_FMT_RGB444BE: return SDL_PIXELFORMAT_RGB444;
#if SDL_VERSION_ATLEAST(2, 0, 12)
case AV_PIX_FMT_BGR444BE: return SDL_PIXELFORMAT_BGR444;
#endif
case AV_PIX_FMT_PAL8: return SDL_PIXELFORMAT_INDEX8;
default: return SDL_PIXELFORMAT_UNKNOWN;
}
Expand Down

0 comments on commit 739ff9d

Please sign in to comment.