A graphics card drawing a client's scenes: a CauldronGPU.Host renderer, offscreen for
pictures shown in the pane or in a window of its own, and the cache a scene's :gpu
function keeps between ticks.
{:ok, stage} = Stage.start(:pane, title: "Quake")
# once {Stage, ^stage, :ready} has arrived:
{:ok, raster} = Stage.picture(stage, scene.gpu, {960, 600}, 1.0)The process that starts a stage is its owner and receives {Stage, stage, message}:
:ready— the renderer has opened;picture/4anddraw/2may be used{:failed, reason}— it did not open, or stopped and could not be started again; the stage has stopped{:input, event}— a key pressed or released in the window, as a terminal's drafter event (Cauldron2D.Drafter.Client.WindowKeys):closed— the window was closed; the stage has stopped
A renderer process that exits is started again with the scene it had, so the cache stays good. The stage stops when its owner exits.
Summary
Functions
Whether this build has CauldronGPU and a renderer to open.
Returns a specification to start this module under a supervisor.
Sends the scene gpu describes to the window. Ticks sent faster than they are drawn are dropped for the newest.
The scene gpu describes drawn at size pixels, as a raster. {:error, reason} when
the renderer is not ready, the function raises, or no frame comes back in time.
Starts a stage owned by the caller, opening its renderer in the background. Options:
:title (the window's title).
Stops the stage, closing its renderer.
Types
@type gpu() :: (term(), term(), {pos_integer(), pos_integer()}, number() -> {list(), term()})
@type mode() :: :pane | :window
@type t() :: pid()
Functions
@spec available?() :: boolean()
Whether this build has CauldronGPU and a renderer to open.
Returns a specification to start this module under a supervisor.
See Supervisor.
Sends the scene gpu describes to the window. Ticks sent faster than they are drawn are dropped for the newest.
@spec picture(t(), gpu(), {pos_integer(), pos_integer()}, number()) :: {:ok, FrenchCurve.Raster.t()} | {:error, term()}
The scene gpu describes drawn at size pixels, as a raster. {:error, reason} when
the renderer is not ready, the function raises, or no frame comes back in time.
Starts a stage owned by the caller, opening its renderer in the background. Options:
:title (the window's title).
@spec stop(t()) :: :ok
Stops the stage, closing its renderer.