Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port imageext.c to SDL3(_image) #3262

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/build-sdl3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ jobs:
cmake --build . --config Release --parallel
sudo cmake --install . --config Release

- name: Install SDL3_image
if: matrix.os != 'windows-latest'
run: |
git clone https://github.com/libsdl-org/SDL_image
cd SDL_image
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --parallel
sudo cmake --install . --config Release

- name: Build with SDL3
run: python3 dev.py build --sdl3

Expand Down
16 changes: 16 additions & 0 deletions buildconfig/download_win_prebuilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def get_urls(x86=True, x64=True):
'71ad2b5aacbc934a39e390ad733421313dd5d059'
],
[
'https://github.com/libsdl-org/SDL_image/releases/download/preview-3.1.0/SDL3_image-devel-3.1.0-VC.zip',
'8538fea0cc4aabba2fc64db06196f1bb76a2785f'
],
[
'https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.22.0/SDL2_ttf-devel-2.22.0-VC.zip',
'2d4f131909af2985b5ebc5ed296d28628c87c243'
],
Expand Down Expand Up @@ -213,6 +217,18 @@ def copy(src, dst):
'SDL2_image-2.8.3'
)
)
copy(
os.path.join(
temp_dir,
'SDL3_image-devel-3.1.0-VC/SDL3_image-3.1.0'
),
os.path.join(
move_to_dir,
prebuilt_dir,
'SDL3_image-3.1.0'
)
)

copy(
os.path.join(
temp_dir,
Expand Down
1 change: 0 additions & 1 deletion dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

SDL3_ARGS = [
"-Csetup-args=-Dsdl_api=3",
"-Csetup-args=-Dimage=disabled",
"-Csetup-args=-Dmixer=disabled",
"-Csetup-args=-Dfont=disabled",
]
Expand Down
14 changes: 10 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
endif

sdl_ver = (sdl_api == 3) ? '3.1.6' : '2.30.10'
sdl_image_ver = '2.8.3'
sdl_image_ver = (sdl_api == 3) ? '3.1.0' : '2.8.3'
sdl_mixer_ver = '2.8.0'
sdl_ttf_ver = '2.22.0'

Expand All @@ -131,12 +131,18 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
pg_lib_dirs += sdl_image_lib_dir
dlls += [
sdl_image_lib_dir / '@[email protected]'.format(sdl_image),
sdl_image_lib_dir / 'optional' / 'libjpeg-62.dll',
sdl_image_lib_dir / 'optional' / 'libpng16-16.dll',
sdl_image_lib_dir / 'optional' / 'libtiff-5.dll',
sdl_image_lib_dir / 'optional' / (sdl_api == 3 ? 'libtiff-6.dll' : 'libtiff-5.dll'),
sdl_image_lib_dir / 'optional' / 'libwebp-7.dll',
sdl_image_lib_dir / 'optional' / 'libwebpdemux-2.dll',
]
# temporary solution to get things compiling under SDL3_image. In the future
# we would want to have libpng and libjpeg on SDL3_image as well.
if sdl_api != 3
dlls += [
sdl_image_lib_dir / 'optional' / 'libjpeg-62.dll',
sdl_image_lib_dir / 'optional' / 'libpng16-16.dll',
]
endif
endif

# SDL_mixer
Expand Down
8 changes: 8 additions & 0 deletions src_c/imageext.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@

#include "pgopengl.h"

#ifdef PG_SDL3
#include <SDL3_image/SDL_image.h>
Starbuck5 marked this conversation as resolved.
Show resolved Hide resolved

// SDL3_images uses SDL3 error reporting API
#define IMG_GetError SDL_GetError
#else
#include <SDL_image.h>
#endif

#ifdef WIN32
#define strcasecmp _stricmp
#else
Expand Down
6 changes: 3 additions & 3 deletions src_c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,6 @@ endif

# optional modules

# TODO: support SDL3
if sdl_api != 3

if sdl_image_dep.found()
imageext = py.extension_module(
'imageext',
Expand All @@ -421,6 +418,9 @@ if sdl_image_dep.found()
)
endif

# TODO: support SDL3
if sdl_api != 3

if sdl_ttf_dep.found()
font = py.extension_module(
'font',
Expand Down
Loading