Skip to main content

Module q_viewport

Module q_viewport 

Source
Expand description

Declarative <q-viewport> lifecycle — types and pure logic (plan §7.3 W5).

The viewport lifecycle is:

  1. Detect backend — call Render.gpu_backend_info to probe WebGPU/WebGL2.
  2. Init GPU — call Render.gpu_init with width/height/particle_cap.
  3. Frame loop — repeatedly call Render.gpu_render_frame with sim-time.
  4. Resize — call Render.gpu_resize when the canvas dimensions change.
  5. Camera — call Render.gpu_set_camera on mouse/wheel input.
  6. Destroy — call Render.gpu_destroy on unmount.
  7. After resize — Render.gpu_sync_bloom then Render.gpu_surface_size.
  8. Pick — Render.gpu_pick + Render.gpu_poll_pick on click.
  9. Camera readback — Render.gpu_camera_state after orbit.

This module contains only the types and pure logic (no UI dependencies). The async invoke functions live in the component module, which has access to the qapp_engine::invoke_json helper.

Structs§

ViewportConfig
Viewport configuration — declarative props for <q-viewport>.
ViewportState
Viewport runtime state — tracks the GPU handle, backend, and frame count.

Enums§

ViewportBackend
Backend type detected by Render.gpu_backend_info.

Functions§

extract_backend
Extract the backend string from a poet_eval result JSON.
extract_handle
Extract the GPU handle from a poet_eval result JSON.
extract_pick
Extract pick result from Render.gpu_poll_pick.
extract_surface_size
Extract {width, height} from Render.gpu_surface_size.
vibe_gpu_script
Workshop-dialect Vibe body for GPU invokes (using Render;).