ElixirDoom.Gpu (elixir_doom v0.2.0)

Copy Markdown View Source

A player's view described for the graphics card, as a scene's :gpu (Cauldron2D.Client.Game): the same picture ElixirDoom.Render draws in software.

{changes, cache} = ElixirDoom.Gpu.draw(view, opts, target, cache, {width, height}, aspect)

The level is a CauldronGPU.Sectors.Live map, uploaded once per level and released when the level changes; its doors, lifts, lights, switches and animated pictures change as the view's sectors and sides do. Things are upright sprites (ElixirDoom.Gpu.Sprites); the weapon, status bar, messages, automap, menus and the screens between levels are the overlay (ElixirDoom.Gpu.Overlay), put again only when it changes, but for a partly invisible player's shimmering weapon (ElixirDoom.Gpu.Weapon); the palette washes are the screen tint (ElixirDoom.Gpu.Tint); the fixed light tables of invulnerability and light amplification draw every picture through that table at full light. Walls and flats are lit in display colour through the live map's light table, darkening with distance.

The camera is the software view's: the eye's position and heading, drawn into the view's window above the status bar (smaller at Doom's smaller screen sizes), a quarter turn across the window's width, and a world unit drawn 1.2 * aspect times taller than wide; at low detail the window shows half as many columns, each two pixels wide. The automap's seen lines are recorded as a 320 by 168 view sees them.

opts are those of ElixirDoom.Render.picture/4.

Summary

Functions

The tick's changes for view drawn at size with pixels aspect wide, and the cache for next time.

Types

cache()

@type cache() :: %{
  level: String.t() | nil,
  live: CauldronGPU.Sectors.Live.t() | nil,
  sprites: ElixirDoom.Gpu.Sprites.t() | nil,
  weapon: CauldronGPU.Handle.t() | nil,
  surroundings: {term(), term()} | nil,
  overlay: CauldronGPU.Handle.t() | nil,
  overlay_rgba: binary() | nil,
  tint: tuple() | nil,
  eye: {number(), number(), number()} | nil
}

Functions

draw(view, opts, target, cache, size, aspect)

@spec draw(
  map(),
  keyword(),
  CauldronGPU.Target.t(),
  cache() | nil,
  {pos_integer(), pos_integer()},
  number()
) :: {[CauldronGPU.Stream.change()], cache()}

The tick's changes for view drawn at size with pixels aspect wide, and the cache for next time.