more webcam stuff
This commit is contained in:
@@ -115,6 +115,12 @@ namespace SDLSurface
|
||||
@[extern "sdl_Surface_get_format"]
|
||||
opaque format : @& SDLSurface -> UInt32
|
||||
|
||||
@[extern "sdl_Surface_get_w"]
|
||||
opaque w : @& SDLSurface -> Int32
|
||||
|
||||
@[extern "sdl_Surface_get_h"]
|
||||
opaque h : @& SDLSurface -> Int32
|
||||
|
||||
end SDLSurface
|
||||
|
||||
@[extern "sdl_image_load"]
|
||||
|
||||
@@ -72,6 +72,18 @@ private def updateEngineState (engineState : IO.Ref EngineState) : IO Unit := do
|
||||
if ← isKeyDown .S then playerY := playerY + 1
|
||||
engineState.set { state with deltaTime, lastTime := currentTime, playerX, playerY }
|
||||
|
||||
|
||||
partial def webcamLoop (renderer: SDL.SDLRenderer) (camera: SDL.SDLCamera): IO Unit := do
|
||||
let frame <- SDL.acquireCameraFrame camera
|
||||
|
||||
let w := frame.w.toUInt32
|
||||
let h := frame.h.toUInt32
|
||||
let texture <- SDL.createTexture renderer frame.format SDL.SDL_TEXTUREACCESS_STREAMING w h
|
||||
|
||||
let () <- SDL.releaseCameraFrame camera frame
|
||||
|
||||
|
||||
|
||||
partial def gameLoop (engineState : IO.Ref EngineState) : IO Unit := do
|
||||
updateEngineState engineState
|
||||
|
||||
|
||||
@@ -278,6 +278,16 @@ uint32_t sdl_Surface_get_format(b_lean_obj_arg surface_obj) {
|
||||
return (uint32_t)surface->format;
|
||||
}
|
||||
|
||||
int32_t sdl_Surface_get_w(b_lean_obj_arg surface_obj) {
|
||||
SDL_Surface* surface = (SDL_Surface*)lean_get_external_data(surface_obj);
|
||||
return (int32_t)surface->w;
|
||||
}
|
||||
|
||||
int32_t sdl_Surface_get_h(b_lean_obj_arg surface_obj) {
|
||||
SDL_Surface* surface = (SDL_Surface*)lean_get_external_data(surface_obj);
|
||||
return (int32_t)surface->h;
|
||||
}
|
||||
|
||||
lean_obj_res sdl_create_texture(b_lean_obj_arg renderer_obj, uint32_t pixel_format, uint32_t texture_access, uint32_t width, uint32_t height) {
|
||||
SDL_Renderer * renderer = (SDL_Renderer *)lean_get_external_data(renderer_obj);
|
||||
SDL_Texture* texture = SDL_CreateTexture(renderer, pixel_format, (SDL_TextureAccess)texture_access, width, height);
|
||||
|
||||
Reference in New Issue
Block a user