Cauldron2D.Drafter.Client.Gpu (Cauldron2D.Drafter v0.3.0)

Copy Markdown View Source

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.

Summary

Functions

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.

The client state after a message from its stage.

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

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

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

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

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

Types

mode()

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

t()

@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
}

Functions

configure(state)

@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(arg1, state)

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

The client state after a message from its stage.

new(options)

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

note(arg1)

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

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

scene(arg1, scene)

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

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

stop(arg1)

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

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

tick(state, arg2)

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

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