# `Cauldron2D.Drafter.Client.Gpu`
[🔗](https://github.com/jaman/cauldron/blob/v0.3.0/cauldron_2d_drafter/lib/cauldron_2d/drafter/client/gpu.ex#L1)

A client's graphics card: where its scenes are drawn, the
`Cauldron2D.Drafter.Client.Stage` that draws them, and what it does to the game's scenes.

Where comes from the picture options (`gpu`, `window` or `software`,
`Cauldron2D.Drafter.Client.Picture`) when they say, else from the player's `drawing`
setting (`Cauldron2D.Drafter.Client.Settings`), whose `:auto` draws on the card in the
pane. The stage starts the first time a scene with a `:gpu` arrives, so a game that
never describes one never starts a renderer.

The client keeps it under `:gpu` in its state:

  * `new/1` and `configure/1` work out where to draw; `configure/1` again after the
    drawing setting changes stops a stage that no longer fits
  * `tick/2`, with each scene, starts the stage when it is wanted and sends the scene
    to a window
  * `scene/2` gives the scene the client draws: in the pane, a scene with a `:gpu` has
    its `:picture` drawn by the stage once it is ready; in a window, the pane's picture
    is empty from the moment the window starts opening; otherwise, and for scenes with
    no `:gpu`, the game's own `:picture` with the `:gpu` key taken out
  * `message/2` takes the stage's messages: window keys go to the app as terminal
    events, and a stage that fails or a window that closes leaves the game's own
    picture in its place
  * `note/1` is a note about the card for the few seconds after it is made; notes are
    made when the card was asked for by name (`gpu`, `window`, or the setting `:pane`
    or `:window`), not for `:auto`
  * `stop/1` stops the stage

While a window is open the client is told keys are released (`{:key_release_support,
true}`); when it closes the terminal's own answer is restored.

# `mode`

```elixir
@type mode() :: :pane | :window | nil
```

# `t`

```elixir
@type t() :: %{
  asked: :pane | :window | :software | nil,
  mode: mode(),
  named?: boolean(),
  tried?: boolean(),
  stage: Cauldron2D.Drafter.Client.Stage.t() | nil,
  ready?: boolean(),
  note: {String.t(), integer()} | nil,
  key_release: boolean() | nil
}
```

# `configure`

```elixir
@spec configure(map()) :: map()
```

The client state with where to draw worked out from its picture options and its
settings' `drawing`; a stage that no longer fits is stopped, and the next scene with a
`:gpu` starts one that does.

# `message`

```elixir
@spec message({module(), pid(), term()}, map()) :: map()
```

The client state after a message from its stage.

# `new`

```elixir
@spec new([Cauldron2D.Drafter.Client.Picture.option()]) :: t()
```

The state of a client whose picture options are `options`, before `configure/1`.

# `note`

```elixir
@spec note(map()) :: String.t() | nil
```

The note about the graphics card to show now, if any.

# `scene`

```elixir
@spec scene(map(), map()) :: map()
```

The scene the client draws for the game's `scene`.

# `stop`

```elixir
@spec stop(map()) :: :ok
```

Stops the client's stage, if it has one.

# `tick`

```elixir
@spec tick(map(), map()) :: map()
```

Starts the stage when the scene wants one, and sends the scene to an open window.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
