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

Initial SDL3 support. #434

Merged
merged 54 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e4868b4
FIXME Initial SDL3 support.
AliceLR Jan 21, 2024
5fae49e
Fix SDL2 builds and add SDL_FRect workaround.
AliceLR Apr 15, 2024
a720b8b
Fix SDL 1.2 builds(?).
AliceLR Apr 15, 2024
3b1ab5a
Update for lastest SDL3 changes.
AliceLR Apr 15, 2024
c438a6e
Initial (temporary) audio implementation.
AliceLR Apr 16, 2024
815d409
Merge branch 'master' into sdl3
AliceLR Apr 16, 2024
a29ffff
Fix Windows builds and regression tests for SDL3.
AliceLR Apr 16, 2024
dffd522
Micro$haft Winblows
AliceLR Apr 16, 2024
4a0b5f0
Better SDL3 pkg-config handling; default to pkgconf.
AliceLR Apr 16, 2024
3958326
Merge branch 'master' into sdl3.
AliceLR May 22, 2024
adecbc2
Move SDL3 audio driver to its own compilation unit (still broken).
AliceLR May 22, 2024
b4f40f7
Fix SDL_PKG_CONFIG_PATH.
AliceLR May 22, 2024
7ae338f
Fix SDL3 audio (needs resampler bugfix).
AliceLR May 22, 2024
90330a7
Update for latest 'main' version/renderer/keysym changes.
AliceLR May 22, 2024
d8ca233
Add support for SDL_HINT_AUDIO_DEVICE_SAMPLE_FRAMES (not that it matt…
AliceLR May 22, 2024
1b133f1
Merge branch 'master' into sdl3
AliceLR May 24, 2024
cb75c15
Merge branch 'master' into sdl3
AliceLR Aug 30, 2024
075220b
Partial fixes to update to SDL3 main (8/29).
AliceLR Aug 30, 2024
3996b48
Merge branch 'master' into sdl3.
AliceLR Aug 30, 2024
62c9736
Fix SDL1.2 and SDL2 builds.
AliceLR Aug 30, 2024
d4c0b6f
Add missing include to event_sdl.c.
AliceLR Aug 30, 2024
7f1ee51
More fixes for current SDL3 main.
AliceLR Aug 30, 2024
9cdfcc0
Update MZX to work with SDL3 8ea38ebe.
AliceLR Aug 30, 2024
914bac2
Merge branch 'master' into sdl3.
AliceLR Nov 1, 2024
c0d4e56
Fixes for SDL 3.1.6; fix softscale and sdlaccel; fix resizing; fix Op…
AliceLR Nov 2, 2024
3b5bd5f
Merge branch 'master' into sdl3
AliceLR Nov 2, 2024
bc26e3e
Add audio_output_channels support to the SDL3 audio driver.
AliceLR Nov 2, 2024
2476de0
Windows (partial) fixes for SDL 3.1.6.
AliceLR Nov 3, 2024
e59f595
Merge branch 'master' into sdl3
AliceLR Nov 3, 2024
b94746f
Do not define SDL_FUNCTION_POINTER_IS_VOID_POINTER
AliceLR Nov 3, 2024
f8e5b3a
Merge branch 'master' into sdl3
AliceLR Nov 4, 2024
35dca23
Enable text events for SDL3.
AliceLR Nov 4, 2024
1568074
Merge branch 'master' into sdl3
AliceLR Nov 4, 2024
26217b9
Switch fully to SDL3-style SDL_CreateWindow.
AliceLR Nov 5, 2024
a390c9b
Clean up SDL_RenderTexture, SDL_FRect/SDL_Rect #ifdefs, misc.
AliceLR Nov 5, 2024
7d65c97
Remove outdated FIXME from SDL3 audio driver.
AliceLR Nov 5, 2024
80dca48
Clean up render_gl.h OpenGL include macros.
AliceLR Nov 6, 2024
ae9c11e
Add new functions to dejank SDL linked and compiled version fetching.
AliceLR Nov 6, 2024
3fa517f
Fix preserving SDL_WINDOW_FULLSCREEN_DESKTOP for SDL2 builds.
AliceLR Nov 6, 2024
3997f0c
Simplify misc. render_sdl.c changes, remove SDL_GL_MakeCurrent call.
AliceLR Nov 6, 2024
3a1b784
Reduce render_sdl.c diff further (hopefully).
AliceLR Nov 7, 2024
c3a5180
Cleanup event_sdl.c hacks, fix unicode fallback default enablement.
AliceLR Nov 7, 2024
3cc519b
Fix SDL_SetJoystick/GamepadEventsEnabled fallback param type.
AliceLR Nov 7, 2024
5e4e88b
Flatten compatibility version checks for SDL_pixels.h.
AliceLR Nov 7, 2024
c022746
Handle another 0/-1 to true/false as a function instead of macro.
AliceLR Nov 7, 2024
6a02046
Fix lack of matching SDL_free for SDL_GetClipboardText.
AliceLR Nov 7, 2024
420a59a
Remove warn() branches on more SDL render functions with changed retu…
AliceLR Nov 7, 2024
cdcd356
Changelog entry for initial SDL3 support.
AliceLR Nov 7, 2024
c3f693b
Check PREFIX/lib/pkgconfig for SDL3 if LIBDIR=.
AliceLR Nov 7, 2024
cb493bd
Prefer boolean over SDL_bool in SDL1/2 -> SDL3 shims.
AliceLR Nov 7, 2024
054a1fa
Remove leftover unused field from sdl_render_data.
AliceLR Nov 7, 2024
b3293e2
SDL2/SDL3 Renderer texture format lists are different types.
AliceLR Nov 7, 2024
13231ad
Revert event_sdl.c key event trace style changes.
AliceLR Nov 7, 2024
2811749
Don't search LIBDIR/pkgconfig for sdl3.pc, it doesn't work.
AliceLR Nov 7, 2024
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
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,33 @@ include arch/compat.inc

ifneq (${BUILD_SDL},)

#
# SDL 3
#
ifeq (${BUILD_SDL},3)
# Check SDL_PKG_CONFIG_PATH and PREFIX/lib/pkgconfig for sdl3.pc.
# Note --with-path is a pkgconf extension.
ifneq ($(and ${SDL_PKG_CONFIG_PATH},$(wildcard ${SDL_PKG_CONFIG_PATH}/sdl3.pc)),)
# nop
else
# Check dependencies prefix instead for LIBDIR=. platforms.
# This is useless for unix/darwin, which should have sdl3.pc in a
# place pkgconf can find through normal means.
ifeq (${LIBDIR},.)
ifneq ($(wildcard ${PREFIX}/lib/pkgconfig/sdl3.pc),)
SDL_PKG_CONFIG_PATH ?= ${PREFIX}/lib/pkgconfig
endif
endif # LIBDIR=.
endif
ifneq (${SDL_PKG_CONFIG_PATH},)
SDL_PKG_CONFIG_FLAGS = --with-path=${SDL_PKG_CONFIG_PATH}
endif

SDL_PREFIX := $(shell ${PKGCONF} ${SDL_PKG_CONFIG_FLAGS} sdl3 --variable=prefix)
SDL_CFLAGS ?= $(shell ${PKGCONF} ${SDL_PKG_CONFIG_FLAGS} sdl3 --cflags)
SDL_LDFLAGS ?= $(shell ${PKGCONF} ${SDL_PKG_CONFIG_FLAGS} sdl3 --libs)
endif # SDL3

#
# SDL 2
#
Expand Down
9 changes: 9 additions & 0 deletions arch/compat.inc
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,12 @@ ifeq (${CLANG_VER_GE_3_3},0)
HAS_F_STACK_PROTECTOR_STRONG ?= 1
endif
endif # clang

#
# Get pkgconf or pkg-config (prefer pkgconf).
#
PKGCONF ?= ${shell \
result=false; \
command -v pkg-config >/dev/null && result=pkg-config; \
command -v pkgconf >/dev/null && result=pkgconf; \
echo $$result; }
10 changes: 6 additions & 4 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ usage() {
echo
echo "Platform-dependent options:"
echo " --enable-sdl Enable SDL backend, typically SDL2 (default)."
echo " --enable-sdl3 Enable SDL3 backend (any version)."
echo " --enable-sdl2 Enable SDL2 backend (any version)."
echo " --enable-sdl1 Enable SDL1 backend (1.2.x)."
echo " --disable-sdl Disable SDL dependencies and features."
Expand Down Expand Up @@ -446,6 +447,7 @@ while [ "$1" != "" ]; do
[ "$1" = "--enable-sdl" ] && SDL="true"
[ "$1" = "--enable-sdl1" ] && SDL="1"
[ "$1" = "--enable-sdl2" ] && SDL="2"
[ "$1" = "--enable-sdl3" ] && SDL="3"

[ "$1" = "--enable-egl" ] && EGL="true"
[ "$1" = "--disable-egl" ] && EGL="false"
Expand Down Expand Up @@ -821,7 +823,7 @@ else
#
# If no specific version of SDL is selected, select SDL2.
#
if [ "$SDL" != "1" ] && [ "$SDL" != "2" ]; then
if [ "$SDL" != "1" ] && [ "$SDL" != "2" ] && [ "$SDL" != "3" ]; then
SDL="2"
fi
echo "Enabling SDL $SDL.x."
Expand Down Expand Up @@ -1139,7 +1141,7 @@ fi
# Force-disable the softscale renderer for SDL 1.2 (requires SDL_Renderer).
#
if [ "$SDL" = "1" ] && [ "$SOFTSCALE" = "true" ]; then
echo "Force-disabling softscale renderer (requires SDL 2)."
echo "Force-disabling softscale renderer (requires SDL 2+)."
SOFTSCALE="false"
SDLACCEL="false"
fi
Expand Down Expand Up @@ -1546,7 +1548,7 @@ else
fi

#
# Softscale renderer (SDL 2)
# Softscale renderer (SDL 2+)
#
if [ "$SOFTSCALE" = "true" ]; then
echo "Softscale renderer enabled."
Expand Down Expand Up @@ -1940,7 +1942,7 @@ else
fi

#
# SDL_GameControllerDB, if enabled. This depends on SDL 2.
# SDL_GameControllerDB, if enabled. This depends on SDL 2+.
#
if [ "$SDL" != "false" ] && [ "$SDL" -ge "2" ] && \
[ "$GAMECONTROLLERDB" = "true" ]; then
Expand Down
19 changes: 19 additions & 0 deletions docs/STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,25 @@ original condition in a block comment after `#endif`.
// more code
```

In complex cases where there is no other option, left-hash indentation is OK:

```
#ifdef CONFIG_GLES
# ifdef CONFIG_RENDER_GL_FIXED
# if SDL_VERSION_ATLEAST(3,0,0)
# include <SDL3/SDL_opengles.h>
# else
# ...
# endif
# endif
# ifdef CONFIG_RENDER_GL_PROGRAM
# ...
# endif
#else
# ...
#endif
```

### Tabulated definitions

In some places where many values or repetitive structs or enums are defined,
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ FIXES

GIT - MZX 2.93c

Initial support for SDL3 has been added, but as it has not been
released yet, no MegaZeux release builds use it currently.
As part of the preparation for SDL3, this release includes many
long-belated changes to the way MegaZeux resizes windows and
calculates the scaled display area within the window (including
Expand Down Expand Up @@ -56,6 +58,9 @@ USERS

DEVELOPERS

+ Added initial support for SDL3. No platforms select SDL3 by
default, but it is now possible to build and test MegaZeux for
platforms that already support the current prerelease (3.1.6).
+ Split the renderer function "set_video_mode" into two renderer
functions "create_window" and "resize_window" to more closely
reflect the reality of SDL2/3. The former is used during
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,12 @@ core_cobjs += ${core_obj}/event_sdl.o ${core_obj}/platform_sdl.o
core_cobjs += ${core_obj}/render_sdl.o

ifeq (${BUILD_AUDIO},1)
ifeq (${BUILD_SDL},3)
core_cobjs += ${audio_obj}/driver_sdl3.o
else
core_cobjs += ${audio_obj}/audio_sdl.o
endif
endif

core_flags += $(SDL_CFLAGS)
core_ldflags += $(SDL_LDFLAGS)
Expand Down
Loading
Loading