Skip to content

libs/sdl: build on Android / GL ES (glColorMaski stub + SDL_SetMainReady)#952

Open
Pign wants to merge 2 commits into
HaxeFoundation:masterfrom
Pign:up/sdl-android-build
Open

libs/sdl: build on Android / GL ES (glColorMaski stub + SDL_SetMainReady)#952
Pign wants to merge 2 commits into
HaxeFoundation:masterfrom
Pign:up/sdl-android-build

Conversation

@Pign

@Pign Pign commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Two small fixes to build the SDL/GL bindings on Android arm64 (GL ES):

  • gl.c: stub glColorMaski to ES_NOT_SUPPORTED — GL ES has no per-MRT colour mask, so the call can't be expressed there. Keeps the desktop path untouched.
  • sdl.c: call SDL_SetMainReady() under #ifdef __ANDROID__ before SDL_Init, so a pure HL/native binary (not wrapped in an Android Activity) doesn't trip SDL's SDL_main check.

Both are guarded by GL ES / __ANDROID__ and have no effect on desktop targets. Rebased onto the current SDL3 master.

Pign and others added 2 commits June 28, 2026 23:50
…p the SDL_main check

A pure HL binary (./hl my.hl from adb shell) is not wrapped in an
Android Activity, so SDL2's Android backend refuses SDL_Init with
"Application didn't initialize properly, did you include SDL_main.h".

Calling SDL_SetMainReady() under #ifdef __ANDROID__ before SDL_Init
tells SDL the main entry is already set up, letting headless tests
proceed at least through SDL_Init. (Actually opening a Window /
GL context still requires an Activity surface, which adb shell
can't provide — that's an Android-app-side concern.)

Android arm64 validation against the latest JIT (8 hand-written
plus Heaps math/transform):

  nullbool.hl              EXIT=0   (Null<Bool> compare via dyn_compare)
  streq2.hl                EXIT=0   (String compare via hl_dyn_compare)
  big.hl                   EXIT=0   (qsort + memo + structs + Math)
  calc.hl                  EXIT=109 = fib(20) % 256
  heapnowin.hl             EXIT=32  = h3d.Vector dot product
                                     + h3d.Matrix rotation transform

The JIT itself is fully working on Android arm64. The only missing
piece for visual Heaps demos is the Android-app wrapper (APK with
SDL2 Activity glue), which is out of scope for the JIT port.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
GL ES has no per-MRT colour-mask. Stub it to ES_NOT_SUPPORTED so the
gl.c HL bindings compile on Android arm64 without pulling the desktop
GL pipeline state.
@Pign Pign force-pushed the up/sdl-android-build branch from ffa1ce7 to de3a57a Compare June 28, 2026 22:05
@Pign

Pign commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the build-android failure: under SDL3 SDL_SetMainReady() is declared in SDL_main.h, which <SDL3/SDL.h> doesn't pull in. Added #include <SDL3/SDL_main.h> (with SDL_MAIN_HANDLED, so it doesn't redefine main in this shared library) guarded by __ANDROID__. Force-pushed the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant