-
Notifications
You must be signed in to change notification settings - Fork 275
SDL3 port #1756
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
SDL3 port #1756
Conversation
re-tested against the 3.1.1 prerelease |
updated to 3.1.3 |
SDL 3.2.0 marks the full release of SDL3 🥳 |
c641c25
to
56e2c65
Compare
This looks good. By default, even with The CI builds it and statically links it in correctly. I think this is good. I'll look into doing a PR based on this in future where we can just stick the static SDL3 build in |
Thoughts about adding this as well? diff --git a/scripts/build.sh b/scripts/build.sh
index 7d73dfdd..fb4c53ea 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -183,6 +183,7 @@ main() {
elif [[ "$build_dir" == "" ]]; then
build_dir="$(get_default_build_dir)"
fi
+ build_dir=$(readlink -f $build_dir)
# arch and platform specific stuff
if [[ "$platform" == "macos" ]]; then
@@ -214,6 +215,21 @@ main() {
export PATH="$(dirname "$lpm_path"):$PATH"
fi
+ if [[ "$force_fallback" != "" ]]; then
+ git clone --depth=1 --branch release-3.2.8 https://github.com/libsdl-org/SDL.git $build_dir/SDL3 &&
+ pushd $build_dir/SDL3 && mkdir build && cd build &&
+ cmake .. -DCMAKE_BUILD_TYPE=release \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DSDL_INSTALL=ON -DSDL_INSTALL_DOCS=OFF -DSDL_DEPS_SHARED=ON \
+ -DSDL_DBUS=ON -DSDL_IBUS=ON -DSDL_AUDIO=OFF -DSDL_GPU=OFF -DSDL_RPATH=OFF -DSDL_PIPEWIRE=OFF \
+ -DSDL_CAMERA=OFF -DSDL_JOYSTICK=OFF -DSDL_HAPTIC=OFF -DSDL_HIDAPI=OFF -DSDL_DIALOG=OFF \
+ -DSDL_POWER=OFF -DSDL_SENSOR=OFF -DSDL_VULKAN=OFF -DSDL_LIBUDEV=OFF -DSDL_SHARED=OFF -DSDL_STATIC=ON \
+ -DSDL_X11=ON -DSDL_WAYLAND=ON -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF -DSDL_VENDOR_INFO=lite-xl \
+ -DCMAKE_INSTALL_PREFIX=$build_dir/prefix &&
+ make -j 8 && make install && popd
+ CFLAGS="-I${build_dir}/prefix/include $CFLAGS"
+ LDFLAGS="-L${build_dir}/prefix/lib $LDFLAGS"
+ fi
+
CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS meson setup \
"${build_dir}" \
--buildtype "$build_type" \ |
float width = luaL_optnumber(L, 4, 0); | ||
float height = luaL_optnumber(L, 5, 0); | ||
|
||
if (width < 1 || height < 1) { | ||
SDL_DisplayMode dm; | ||
SDL_GetCurrentDisplayMode(0, &dm); | ||
const SDL_DisplayMode* dm = SDL_GetCurrentDisplayMode(SDL_GetPrimaryDisplay()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should first create the window then resize it given the display it opened on (SDL_GetDisplayForWindow
).
Not really a blocker for this PR, just noting this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would not work on Wayland
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, I wonder if there's some leeway given that the resize happens just after we create the window.
Or maybe there's a way to know which monitor is active (aka the window will be created on), and use that.
The main issue (that probably currently happens anyways) is that if the user has wildly different sized monitors, the window might get created too big to fit the screen.
// Seems like SDL doesn't handle clipping as we expect when using | ||
// scaled blitting, so we "clip" manually. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth it to check if this got fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code for this did not change in SDL3 (not for the last 5 years).
I looked at the code and I'm not sure what you meant by "doesn't handle clipping as we expect".
It does seemingly clip the rectangles when the coordinates are off-screen,
and your commit was from 2 years ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am talking about my code. At the time I tried to leave the clipping completely to SDL, but it didn't work as expected. I don't remember what was wrong tho.
This is why I'm hoping SDL3 fixed the issue and we can drop the extra code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but looking at the code it seems like the kind of clipping we do explicitly is done by SDL_BlitScaled. The code in thst function had not changed since 5 years ago, so I assume whatever problems with it is not fixed.
However, I didn't observe anything off with the clipping. I also don't know what to look for.
the main implementation is now included in a header
This needs to be included to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to update the docs for the functions that now need a window
parameter.
Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
Will do this when I have time in another PR. |
🎉 |
* update to SDL 3.2.0 * remove SDL wrap * fix darwin and windows CI * update build box, correct msys sdl3 dependency * port leftovers from renderer backend to SDL3 * remove SDL main dep the main implementation is now included in a header * main.c: use SDL_main.h This needs to be included to work. * ci: use vcpkg and pkgconf to support SDL3 on MSVC * ci: use 7z to create zip * renwindow: create texture and surface suitable for the display * system: remove trailing whitespace * renderer: fix trailing whitespace * system: fix checking the wrong argument * system: port rmdir and stat to SDL3 API * system: remove unneeded API level check * system: fix wrong parameter index * system: make set_window_hit_test and set_window_bordered accept a window * docs/system: update docs * system: restore some comments * docs/system: add missing documentation for system.text_input * system: use SDL_setenv_unsafe * system: add back comment for setenv * system,renderer: remove unnecessary SDL_ClearError calls --------- Co-authored-by: takase1121 <20792268+takase1121@users.noreply.github.com> (cherry picked from commit 2716f14)
* update to SDL 3.2.0 * remove SDL wrap * fix darwin and windows CI * update build box, correct msys sdl3 dependency * port leftovers from renderer backend to SDL3 * remove SDL main dep the main implementation is now included in a header * main.c: use SDL_main.h This needs to be included to work. * ci: use vcpkg and pkgconf to support SDL3 on MSVC * ci: use 7z to create zip * renwindow: create texture and surface suitable for the display * system: remove trailing whitespace * renderer: fix trailing whitespace * system: fix checking the wrong argument * system: port rmdir and stat to SDL3 API * system: remove unneeded API level check * system: fix wrong parameter index * system: make set_window_hit_test and set_window_bordered accept a window * docs/system: update docs * system: restore some comments * docs/system: add missing documentation for system.text_input * system: use SDL_setenv_unsafe * system: add back comment for setenv * system,renderer: remove unnecessary SDL_ClearError calls --------- Co-authored-by: takase1121 <20792268+takase1121@users.noreply.github.com> (cherry picked from commit 2716f14)
* update to SDL 3.2.0 * remove SDL wrap * fix darwin and windows CI * update build box, correct msys sdl3 dependency * port leftovers from renderer backend to SDL3 * remove SDL main dep the main implementation is now included in a header * main.c: use SDL_main.h This needs to be included to work. * ci: use vcpkg and pkgconf to support SDL3 on MSVC * ci: use 7z to create zip * renwindow: create texture and surface suitable for the display * system: remove trailing whitespace * renderer: fix trailing whitespace * system: fix checking the wrong argument * system: port rmdir and stat to SDL3 API * system: remove unneeded API level check * system: fix wrong parameter index * system: make set_window_hit_test and set_window_bordered accept a window * docs/system: update docs * system: restore some comments * docs/system: add missing documentation for system.text_input * system: use SDL_setenv_unsafe * system: add back comment for setenv * system,renderer: remove unnecessary SDL_ClearError calls --------- Co-authored-by: takase1121 <20792268+takase1121@users.noreply.github.com> (cherry picked from commit 2716f14)
builds against the prerelease
wrap is still being worked on
appears to work from simple testing.