17 Commits
Author SHA1 Message Date
Greg ShuflinandClaude Fable 5.1 8104955c71 Make the webcam demo run on macOS
Lean runs main on a helper thread, which Cocoa rejects for video init;
export LEAN_MAIN_USE_THREAD=0 from the justfile on macOS. Wait for the
camera permission event before reading the camera format, since SDL
grants access asynchronously.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-08 15:26:20 -07:00
Greg Shuflin ab65bd39e1 Don't need separate run/main 2026-07-08 23:00:18 -07:00
Greg Shuflin 06293f9fb8 Don't actually need partial here 2026-07-08 22:59:40 -07:00
Greg Shuflin 23bead30bb Remove unused code from webcam demo 2026-07-08 22:21:03 -07:00
Greg ShuflinandClaude Opus 4.6 1830995cc5 Remove opaque Pixels type; add safe updateTexture and zero-copy updateTextureFromSurface
The opaque Pixels type wrapped a void* pointing into an SDL_Surface's
pixel buffer, but nothing tied the Pixels lifetime to the surface. If
the GC collected the surface first, the Pixels pointer would dangle,
causing use-after-free.

Replace with two safe alternatives:

- updateTexture now takes a ByteArray (Lean-owned, GC-managed buffer)
  plus pitch, matching how Haskell's sdl2 uses ByteString and Rust's
  rust-sdl2 uses &[u8]. This is faithful to SDL_UpdateTexture's general
  void* interface but requires copying pixels into a ByteArray first.

- updateTextureFromSurface is a new zero-copy convenience that takes an
  SDLSurface directly. The C side extracts both pixels and pitch from
  the surface internally. Because the surface is borrowed (@&) for the
  call's duration, the GC cannot collect it mid-use. This is not
  strictly faithful to SDL_UpdateTexture's C API, but is the common
  case and avoids an unnecessary memcpy.

Also removes: Pixels type, Pixels.nonemptyType, sdl_pixels_external_class,
sdl_Surface_get_pixels, and the pixels_external_class registration in
sdl_init.

WebcamApp.lean is updated to use updateTextureFromSurface.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 13:41:24 -07:00
Greg Shuflin 62c72f978a Threw claude at the problem - webcam works now 2025-12-26 23:15:55 -08:00
Greg Shuflin 52b882daaf render texture rect partially done 2025-12-25 19:44:20 -08:00
Greg Shuflin 71ddbdeb5a texture updating + pixels 2025-12-25 18:44:18 -08:00
Greg Shuflin 93262301b5 lean webcamLoop modifications 2025-12-25 18:01:01 -08:00
Greg Shuflin 37fbf85118 SDLRect as lean structure 2025-12-25 04:23:29 -08:00
Greg Shuflin 38aa7e316b more webcam stuff 2025-12-24 02:53:47 -08:00
Greg Shuflin 6d7a079f1e more camera type stuff 2025-12-23 23:37:22 -08:00
Greg Shuflin fbab89c3ad working cameraSpec 2025-12-18 03:15:45 -08:00
Greg Shuflin 1b562dfb5b Use camera 2025-12-17 16:49:39 -08:00
Greg Shuflin 65a5f3c066 Working on camera code 2025-12-17 03:10:58 -08:00
Greg Shuflin 6418561029 sdl_create_window_and_renderer 2025-12-16 00:28:37 -08:00
Greg Shuflin 9b4f5f7926 Add webcam app example (initial, same as test-app) 2025-12-15 19:40:35 -08:00