Skip to content

cvcgl: add SDL3 dependency (input + peripheral seam foundation) - #440

Merged
transfix merged 2 commits into
masterfrom
design/cvcgl-sdl
Sep 28, 2026
Merged

transfix merged 2 commits into
masterfrom
design/cvcgl-sdl

Conversation

@transfix

Copy link
Copy Markdown
Owner

Add SDL3 as a cvcGL dependency — the input + peripheral seam foundation

Wires SDL3 into cvcGL so we can rely on it for keyboard / mouse / gamepad input
(and later audio / microphone / camera), native and wasm/wasm-mt (verified with
VTK). This replaces the earlier plan for a bespoke Backend key-event API with a real
cross-platform input source, and is the foundation for the §4.6 pointer/input handlers
(on_key / on_click / on_drag / …) and the .ari VolRover3's later audio/peripheral
needs. (VR — an OpenXR↔WebXR bridge — is future research.)

What this does (declares + wires the dependency)

  • cvcgl recipe (cvcpkg/recipes/cvcgl/recipe.yaml): sdl3 added to
    depends.build + depends.runtime; cvc_revision 2 → 3 (the export now links
    SDL3::SDL3, so a consumer of cvc::cvcGL must have sdl3 in its prefix — a
    superseding republish).
  • src/cvcGL/CMakeLists.txt: find_package(SDL3 CONFIG QUIET) behind
    CVC_ENABLE_SDL (ON) — links SDL3::SDL3 + defines CVC_ENABLE_SDL when present;
    gracefully absent otherwise (input falls back to the VTK interactor, as today).
    Mirrors the existing imgui integration exactly.
  • cvcGLConfig.cmake.in: @CVCGL_SDL_DEP@ re-finds SDL3 for downstream consumers
    (find_dependency(SDL3)), like @CVCGL_IMGUI_DEP@.

Scope

No SDL is called yet — this PR declares + wires the dependency. The input seam (an
SDL-backed Backend feeding the on_* resident handlers) is the next step, built against
a real SDL prefix.

Verification

  • Local (SDL3 absent): CVC_ENABLE_SDL gracefully off, cvcGL builds + links
    unchanged (no regression) — confirmed (cvcGL: SDL3 not found -- input seam falls back to the VTK interactor).
  • Recipe CI: installs the declared sdl3 dependency, so find_package(SDL3) finds it
    and the SDL3::SDL3 link is exercised on every platform (this is where the actual SDL
    link is validated — SDL3 is not in the local dev deps prefix).

@transfix

Copy link
Copy Markdown
Owner Author

Added cvc::gl::SdlInput (commit 1958bab): the SDL event source that translates SDL3 key/mouse events into a normalized, SDL-free InputEvent. So this PR is now SDL dependency + the SDL half of the §4.6 input seam — SDL is actually used (the link is exercised by real symbols + a test), not just declared.

Verified locally by installing sdl3 3.4.12+cvc.3 into the deps prefix: CVC_ENABLE_SDL flips ON, cvcGL links SDL3, and cvcgl_sdl_input pushes synthetic SDL key/mouse events and confirms the translation ("OK: SDL input translated (3 events)"). The no-SDL build stays inert (VTK-interactor path). The all-platform SDL link + this new source are validated by the recipe CI.

Next (separate, needs the async PR #437's resident machinery): route these InputEvents onto the runtime's per-handler channels so on_key/on_click/on_drag/on_hover residents fire — plus an event-watch/ownership split for hosts where VTK also pumps SDL (wasm).

Adds SDL3 to cvcGL so it can rely on it for keyboard/mouse/gamepad input (and later
audio/microphone/camera), native AND wasm/wasm-mt (verified with VTK). This is the
foundation for the §4.6 pointer/input handlers (on_key/on_click/on_drag/…) — a real
cross-platform input source, instead of a bespoke Backend key-event API — and for the
`.ari` volrover3's later audio/peripheral needs. VR (OpenXR↔WebXR) is future research.

- cvcgl recipe: `sdl3` added to depends.build + depends.runtime; cvc_revision 2 -> 3
  (the export now links SDL3::SDL3, so a consumer of cvc::cvcGL must have sdl3 in its
  prefix — a superseding republish).
- src/cvcGL/CMakeLists.txt: find_package(SDL3 CONFIG QUIET) behind CVC_ENABLE_SDL (ON),
  links SDL3::SDL3 + defines CVC_ENABLE_SDL when present; GRACEFULLY ABSENT otherwise
  (input falls back to the VTK interactor, as today). Mirrors the imgui integration.
- cvcGLConfig.cmake.in: @CVCGL_SDL_DEP@ re-finds SDL3 for consumers (find_dependency),
  like @CVCGL_IMGUI_DEP@.

No SDL is CALLED yet — this declares + wires the dependency; the input seam (an
SDL-backed Backend feeding the on_* resident handlers) is the next step, built against a
real SDL prefix. Verified locally: with no SDL3 in the deps prefix, CVC_ENABLE_SDL is off
and cvcGL builds + links unchanged (no regression). The actual SDL3 link is verified by
the recipe CI, which installs the declared sdl3 dependency.
Builds on the sdl3 dependency: cvc::gl::SdlInput turns SDL3's OS input events into a
small, SDL-free normalized InputEvent (KeyDown/KeyUp/MouseMove/MouseButton*/MouseWheel with
key/mods/x/y/dx/dy/button/clicks). SDL is confined to SdlInput.cpp — the public header
exposes no SDL types, so a cvcGL consumer needs no SDL headers.

- init() brings up the SDL EVENTS subsystem only (no window/video → headless-safe; a windowed
  host that already SDL_Init(VIDEO)'d shares the refcounted subsystem); poll() drains the SDL
  queue and returns the translated keyboard/mouse events (other event types left for the host).
- Gated by CVC_ENABLE_SDL: without SDL the source is inert (init() false, poll() empty) and a
  host uses the VTK interactor as today. SdlInput.cpp is always compiled (the file glob), SDL
  body #ifdef'd — same shape as the imgui integration.

This is the SDL producer for the on_* resident handlers (on_key/on_click/on_drag/on_hover); the
routing of these events onto the Ariadne runtime's per-handler channels is the next step (needs
the resident machinery from the async PR). NB SdlInput.poll() drains the shared SDL queue, so a
host that also lets VTK pump SDL (wasm) will need an event-watch/ownership split — a follow-up.

Verified LOCALLY (sdl3 installed into the deps prefix): +1 test cvcgl_sdl_input pushes synthetic
SDL key/mouse events and confirms the translation ("OK: SDL input translated (3 events)"). The
no-SDL build stays inert. The all-platform SDL link is green in the recipe CI.
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