Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
02bae94
Port hlsdl to SDL3
nspitko Sep 18, 2025
6a710ce
Enable -DDOWNLOAD-DEPENDENCIES for linux
nspitko Sep 18, 2025
d15aea9
Remove syswm.h include, add linux deps
nspitko Sep 18, 2025
2fa3309
Remove extra terminator
nspitko Sep 18, 2025
0625c8e
Remove syntactically significant whitespace
nspitko Sep 18, 2025
a2feaee
Remove dead code for HL_MOBILE
nspitko Sep 18, 2025
feeb331
Update Makefile
nspitko Sep 18, 2025
6aaf85f
Try building SDL locally on linux runners
nspitko Sep 18, 2025
959fd04
Remove setup SDL action, it's broken
nspitko Sep 18, 2025
6d9c5ea
Fix memory leaks, manually install SDL on linux
nspitko Sep 19, 2025
bf21e88
Fix build errors
nspitko Sep 19, 2025
c53a6b0
SDL_Free -> SDL_free, fix warning
nspitko Sep 19, 2025
d077ea3
Workflow fix
nspitko Sep 19, 2025
8dd0195
SDL_GetJoysticks returns SDL_JoystickID*, not SDL_Joystick*
nspitko Sep 19, 2025
1ecc107
Remove -I $(BREW_SDL_PREFIX)/include/SDL3, fix IOS
nspitko Sep 19, 2025
163800e
Fix controller hotplug
nspitko Sep 20, 2025
61eb575
Merge branch 'HaxeFoundation:master' into sdl3
nspitko Sep 20, 2025
9881974
Maintain API compatibility with SDL2
nspitko Sep 20, 2025
eb9440a
Merge branch 'sdl3' of https://github.com/nspitko/hashlink into sdl3
nspitko Sep 20, 2025
67c2dfd
Add missing window flags, fix SDL_SetEventEnabled
nspitko Sep 20, 2025
2971fec
Emulate SDL_GRAB_KEYBOARD
nspitko Sep 20, 2025
146c810
Add missing cast
nspitko Sep 20, 2025
5b84dea
Fix missing bool
nspitko Sep 20, 2025
a45b7ce
jdevice->gdevice
nspitko Sep 21, 2025
1849d6f
add getJoysticks. Bump version.
nspitko Sep 23, 2025
21bfe52
SDL_Joystick -> SDL_JoystickID
nspitko Sep 23, 2025
c03200b
Update haxelib.json
nspitko Sep 25, 2025
71b8f2d
fix text input
nspitko Oct 16, 2025
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
49 changes: 45 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,39 @@ jobs:
libmbedtls-dev \
libopenal-dev \
libpng-dev \
libsdl2-dev \
libturbojpeg-dev \
libuv1-dev \
libvorbis-dev \
libsqlite3-dev

# ref https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies
sudo apt-get install --no-install-recommends -y \
libasound2-dev \
libpulse-dev \
libaudio-dev \
libjack-dev \
libsndio-dev \
libx11-dev \
libxext-dev \
libxrandr-dev \
libxcursor-dev \
libxfixes-dev \
libxi-dev \
libxss-dev \
libxtst-dev \
libxkbcommon-dev \
libdrm-dev \
libgbm-dev \
libgl1-mesa-dev \
libgles2-mesa-dev \
libegl1-mesa-dev \
libdbus-1-dev \
libibus-1.0-dev \
libudev-dev \
libpipewire-0.3-dev \
libwayland-dev \
libdecor-0-dev \
liburing-dev
;;

darwin*)
Expand All @@ -143,10 +171,10 @@ jobs:
;;

windows*)
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/sdl.zip https://www.libsdl.org/release/SDL2-devel-2.30.2-VC.zip
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/sdl.zip https://github.com/libsdl-org/SDL/releases/download/release-3.2.22/SDL3-devel-3.2.22-VC.zip
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/openal.zip https://github.com/kcat/openal-soft/releases/download/1.23.1/openal-soft-1.23.1-bin.zip
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/ffmpeg.zip ${{ matrix.ffmpeg_url }}
7z x /tmp/sdl.zip -oinclude; mv include/SDL2* include/sdl
7z x /tmp/sdl.zip -oinclude; mv include/SDL3* include/sdl
7z x /tmp/openal.zip -oinclude; mv include/openal* include/openal
7z x /tmp/ffmpeg.zip -oinclude; mv include/ffmpeg* include/ffmpeg
;;
Expand Down Expand Up @@ -174,6 +202,18 @@ jobs:
haxelib install hashlink
haxelib list

- name: "Build and install SDL3"
if: runner.os == 'Linux'
run: |
wget https://github.com/libsdl-org/SDL/releases/download/release-3.2.22/SDL3-3.2.22.tar.gz
tar -xzvf SDL3-3.2.22.tar.gz
cd SDL3-3.2.22/
mkdir build
cd build
cmake ..
make
sudo make install


- name: "Build: HashLink"
run: |
Expand Down Expand Up @@ -202,7 +242,8 @@ jobs:
-DFLAT_INSTALL_TREE=ON
;;
linux64)
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }} ;;
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.cmake_configuration }}
;;
esac

cmake --build build --config ${{ matrix.cmake_configuration }}
Expand Down
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
brew "cmake"
brew "jpeg-turbo"
brew "libpng"
brew "sdl2"
brew "sdl3"
brew "libogg"
brew "libvorbis"
brew "openal-soft"
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ ifeq ($(MARCH),32)
CFLAGS += -msse2 -mfpmath=sse
CC=i686-pc-cygwin-gcc
BUILD_DIR = Release
VS_SDL_LIBRARY ?= include/sdl/lib/x86/SDL2.dll
VS_SDL_LIBRARY ?= include/sdl/lib/x86/SDL3.dll
VS_OPENAL_LIBRARY ?= include/openal/bin/Win32/soft_oal.dll
else
BUILD_DIR = x64/Release
VS_SDL_LIBRARY ?= include/sdl/lib/x64/SDL2.dll
VS_SDL_LIBRARY ?= include/sdl/lib/x64/SDL3.dll
VS_OPENAL_LIBRARY ?= include/openal/bin/Win64/soft_oal.dll
endif

Expand All @@ -152,9 +152,9 @@ LIBEXT=dylib
BREW_PREFIX := $(shell brew --prefix)
# prefixes for keg-only packages
BREW_OPENAL_PREFIX := $(shell brew --prefix openal-soft)
BREW_SDL_PREFIX := $(shell brew --prefix sdl2)
BREW_SDL_PREFIX := $(shell brew --prefix sdl3)

CFLAGS += -m$(MARCH) -I include -I $(BREW_PREFIX)/include -I $(BREW_OPENAL_PREFIX)/include -I $(BREW_SDL_PREFIX)/include/SDL2 -Dopenal_soft -DGL_SILENCE_DEPRECATION
CFLAGS += -m$(MARCH) -I include -I $(BREW_PREFIX)/include -I $(BREW_OPENAL_PREFIX)/include -Dopenal_soft -DGL_SILENCE_DEPRECATION
LFLAGS += -Wl,-export_dynamic

ifdef OSX_SDK
Expand All @@ -163,7 +163,7 @@ CFLAGS += -isysroot $(ISYSROOT)
LFLAGS += -isysroot $(ISYSROOT)
endif

SDL_LINK_FLAGS = -L$(BREW_SDL_PREFIX)/lib -lSDL2
SDL_LINK_FLAGS = -L$(BREW_SDL_PREFIX)/lib -lSDL3
LIBFLAGS += -L$(BREW_PREFIX)/lib -L$(BREW_OPENAL_PREFIX)/lib
LIBOPENGL = -framework OpenGL
LIBOPENAL = -lopenal
Expand All @@ -185,7 +185,7 @@ LHL_LINK_FLAGS += -install_name @rpath/libhl.dylib
else

# Linux
CFLAGS += -m$(MARCH) -fPIC -pthread -fno-omit-frame-pointer $(shell pkg-config --cflags sdl2)
CFLAGS += -m$(MARCH) -fPIC -pthread -fno-omit-frame-pointer $(shell pkg-config --cflags sdl3)
LFLAGS += -lm -Wl,-rpath,.:'$$ORIGIN':$(INSTALL_LIB_DIR) -Wl,--export-dynamic -Wl,--no-undefined

ifeq ($(MARCH),32)
Expand All @@ -195,7 +195,7 @@ else
LIBFLAGS += -L/opt/libjpeg-turbo/lib64
endif

SDL_LINK_FLAGS = $(shell pkg-config --libs sdl2)
SDL_LINK_FLAGS = $(shell pkg-config --libs sdl3)
LIBOPENAL = -lopenal
LIBOPENGL = -lGL
RELEASE_NAME = linux
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ Here's the dependencies that you install in order to compile all the libraries:

* fmt: libpng-dev libturbojpeg-dev libvorbis-dev
* openal: libopenal-dev
* sdl: libsdl2-dev libglu1-mesa-dev
* sdl: libsdl3-dev libglu1-mesa-dev
* ssl: libmbedtls-dev
* uv: libuv1-dev
* sqlite: libsqlite3-dev

To install all dependencies on the latest **Ubuntu**, for example:

`sudo apt-get install libpng-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl2-dev libglu1-mesa-dev libmbedtls-dev libuv1-dev libsqlite3-dev`
`sudo apt-get install libpng-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl3-dev libglu1-mesa-dev libmbedtls-dev libuv1-dev libsqlite3-dev`

For 16.04, see [this note](https://github.com/HaxeFoundation/hashlink/issues/147).

To install all dependencies on the latest **Fedora**, for example:

`sudo dnf install libpng-devel turbojpeg-devel libvorbis-devel openal-soft-devel SDL2-devel mesa-libGLU-devel mbedtls-devel libuv-devel sqlite-devel`
`sudo dnf install libpng-devel turbojpeg-devel libvorbis-devel openal-soft-devel SDL3-devel mesa-libGLU-devel mbedtls-devel libuv-devel sqlite-devel`

**And on OSX:**

Expand All @@ -53,7 +53,7 @@ To build all of HashLink libraries it is required to download several additional

In short you'll probably need:

- [SDL2-devel](https://github.com/libsdl-org/SDL/releases/download/release-2.30.12/SDL2-devel-2.30.12-VC.zip), extract to `<hashlink>/include/sdl`
- [SDL3-devel](https://github.com/libsdl-org/SDL/releases/download/release-3.2.22/SDL3-devel-3.2.22-VC.zip), extract to `<hashlink>/include/sdl`
- [openal-soft](https://github.com/kcat/openal-soft/releases/download/1.23.1/openal-soft-1.23.1-bin.zip), extract to `<hashlink>/include/openal`

## Debugging
Expand Down
14 changes: 7 additions & 7 deletions libs/sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ add_library(sdl.hdll

if ((NOT WIN32) AND DOWNLOAD_DEPENDENCIES)
FetchContent_Declare(
SDL2
URL https://github.com/libsdl-org/SDL/releases/download/release-2.32.8/SDL2-2.32.8.tar.gz
URL_HASH SHA256=0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e
SDL3
URL https://github.com/libsdl-org/SDL/releases/download/release-3.2.22/SDL3-3.2.22.tar.gz
URL_HASH SHA256=f29d00cbcee273c0a54f3f32f86bf5c595e8823a96b1d92a145aac40571ebfcc
DOWNLOAD_EXTRACT_TIMESTAMP true
EXCLUDE_FROM_ALL
)
Expand All @@ -22,13 +22,13 @@ if ((NOT WIN32) AND DOWNLOAD_DEPENDENCIES)
set(SDL_STATIC_PIC ON CACHE INTERNAL "")
endif()
endif()
FetchContent_MakeAvailable(SDL2)
FetchContent_MakeAvailable(SDL3)
else()
if(WIN32)
set(SDL2_DIR ${INCLUDES_BASE_DIR}/sdl/cmake)
set(SDL3_DIR ${INCLUDES_BASE_DIR}/sdl/cmake)
endif()

find_package(SDL2 REQUIRED)
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
endif()

set_as_hdll(sdl)
Expand All @@ -38,7 +38,7 @@ target_include_directories(sdl.hdll
)
target_link_libraries(sdl.hdll
libhl
SDL2::SDL2
SDL3::SDL3
)
if(APPLE)
target_compile_definitions(sdl.hdll PRIVATE GL_SILENCE_DEPRECATION)
Expand Down
4 changes: 2 additions & 2 deletions libs/sdl/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
hlsdl
=====

HLSDL is a SDL2 backend for HashLink
HLSDL is a SDL3 backend for HashLink
Read https://www.libsdl.org/ for more information on SDL

In order to compile on Windows, download the Development Libraries from SDL2 and unzip them into the hashlink/include/sdl directory, so you have the directories hashlink/include/sdl/include and hashlink/include/sdl/lib available.
In order to compile on Windows, download the Development Libraries from SDL3 and unzip them into the hashlink/include/sdl directory, so you have the directories hashlink/include/sdl/include and hashlink/include/sdl/lib available.


11 changes: 5 additions & 6 deletions libs/sdl/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
#include "hlsystem.h"

#if defined(HL_IOS) || defined (HL_TVOS)
# include <SDL.h>
# include <SDL_syswm.h>
# include <SDL3/SDL.h>
# include <OpenGLES/ES3/gl.h>
# define HL_GLES
#elif defined(HL_MAC)
# include <SDL.h>
# include <SDL3/SDL.h>
# include <OpenGL/gl3.h>
# define glBindImageTexture(...) hl_error("Not supported on OSX")
# define glDispatchCompute(...) hl_error("Not supported on OSX")
# define glMemoryBarrier(...) hl_error("Not supported on OSX")
#elif defined(_WIN32)
# include <SDL.h>
# include <SDL3/SDL.h>
# include <GL/GL.h>
# include <glext.h>
#elif defined(HL_CONSOLE)
Expand All @@ -24,12 +23,12 @@
# include <GL/osmesa.h>
# define HL_GLES
#elif defined(HL_ANDROID)
# include <SDL.h>
# include <SDL3/SDL.h>
# include <GLES3/gl32.h>
# include <GLES3/gl3ext.h>
# define HL_GLES
#else
# include <SDL.h>
# include <SDL3/SDL.h>
# include <GL/glcorearb.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion libs/sdl/haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license" : "BSD",
"contributors" : ["ncannasse"],
"description" : "SDL/GL support for Haxe/HL.",
"version" : "1.16.0",
"version" : "1.17.0",
"releasenote" : "",
"dependencies": {}
}
Loading
Loading