Skip to content

Commit 2973c8b

Browse files
committed
Port imageext.c to SDL3(_image)
1 parent a8c2997 commit 2973c8b

File tree

6 files changed

+48
-8
lines changed

6 files changed

+48
-8
lines changed

.github/workflows/build-sdl3.yml

+11
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ jobs:
8686
cmake --build . --config Release --parallel
8787
sudo cmake --install . --config Release
8888
89+
- name: Install SDL3_image
90+
if: matrix.os != 'windows-latest'
91+
run: |
92+
git clone https://github.com/libsdl-org/SDL_image
93+
cd SDL_image
94+
mkdir build
95+
cd build
96+
cmake -DCMAKE_BUILD_TYPE=Release ..
97+
cmake --build . --config Release --parallel
98+
sudo cmake --install . --config Release
99+
89100
- name: Build with SDL3
90101
run: python3 dev.py build --sdl3
91102

buildconfig/download_win_prebuilt.py

+16
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def get_urls(x86=True, x64=True):
9090
'71ad2b5aacbc934a39e390ad733421313dd5d059'
9191
],
9292
[
93+
'https://github.com/libsdl-org/SDL_image/releases/download/preview-3.1.0/SDL3_image-devel-3.1.0-VC.zip',
94+
'8538fea0cc4aabba2fc64db06196f1bb76a2785f'
95+
],
96+
[
9397
'https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.22.0/SDL2_ttf-devel-2.22.0-VC.zip',
9498
'2d4f131909af2985b5ebc5ed296d28628c87c243'
9599
],
@@ -213,6 +217,18 @@ def copy(src, dst):
213217
'SDL2_image-2.8.3'
214218
)
215219
)
220+
copy(
221+
os.path.join(
222+
temp_dir,
223+
'SDL3_image-devel-3.1.0-VC/SDL3_image-3.1.0'
224+
),
225+
os.path.join(
226+
move_to_dir,
227+
prebuilt_dir,
228+
'SDL3_image-3.1.0'
229+
)
230+
)
231+
216232
copy(
217233
os.path.join(
218234
temp_dir,

dev.py

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
SDL3_ARGS = [
2828
"-Csetup-args=-Dsdl_api=3",
29-
"-Csetup-args=-Dimage=disabled",
3029
"-Csetup-args=-Dmixer=disabled",
3130
"-Csetup-args=-Dfont=disabled",
3231
]

meson.build

+10-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
110110
endif
111111

112112
sdl_ver = (sdl_api == 3) ? '3.1.6' : '2.30.10'
113-
sdl_image_ver = '2.8.3'
113+
sdl_image_ver = (sdl_api == 3) ? '3.1.0' : '2.8.3'
114114
sdl_mixer_ver = '2.8.0'
115115
sdl_ttf_ver = '2.22.0'
116116

@@ -131,12 +131,18 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
131131
pg_lib_dirs += sdl_image_lib_dir
132132
dlls += [
133133
sdl_image_lib_dir / '@[email protected]'.format(sdl_image),
134-
sdl_image_lib_dir / 'optional' / 'libjpeg-62.dll',
135-
sdl_image_lib_dir / 'optional' / 'libpng16-16.dll',
136-
sdl_image_lib_dir / 'optional' / 'libtiff-5.dll',
134+
sdl_image_lib_dir / 'optional' / (sdl_api == 3 ? 'libtiff-6.dll' : 'libtiff-5.dll'),
137135
sdl_image_lib_dir / 'optional' / 'libwebp-7.dll',
138136
sdl_image_lib_dir / 'optional' / 'libwebpdemux-2.dll',
139137
]
138+
# temporary solution to get things compiling under SDL3_image. In the future
139+
# we would want to have libpng and libjpeg on SDL3_image as well.
140+
if sdl_api != 3
141+
dlls += [
142+
sdl_image_lib_dir / 'optional' / 'libjpeg-62.dll',
143+
sdl_image_lib_dir / 'optional' / 'libpng16-16.dll',
144+
]
145+
endif
140146
endif
141147

142148
# SDL_mixer

src_c/imageext.c

+8
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@
4646

4747
#include "pgopengl.h"
4848

49+
#ifdef PG_SDL3
50+
#include <SDL3_image/SDL_image.h>
51+
52+
// SDL3_images uses SDL3 error reporting API
53+
#define IMG_GetError SDL_GetError
54+
#else
4955
#include <SDL_image.h>
56+
#endif
57+
5058
#ifdef WIN32
5159
#define strcasecmp _stricmp
5260
#else

src_c/meson.build

+3-3
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,6 @@ endif
407407

408408
# optional modules
409409

410-
# TODO: support SDL3
411-
if sdl_api != 3
412-
413410
if sdl_image_dep.found()
414411
imageext = py.extension_module(
415412
'imageext',
@@ -421,6 +418,9 @@ if sdl_image_dep.found()
421418
)
422419
endif
423420

421+
# TODO: support SDL3
422+
if sdl_api != 3
423+
424424
if sdl_ttf_dep.found()
425425
font = py.extension_module(
426426
'font',

0 commit comments

Comments
 (0)