natiny.surface.create

Lua
natiny.surface.create(width, height [, format [, depth]]) -> surface

Creates an off-screen render target: one colour texture, and a depth buffer of its own unless it is asked for without one.

Parameters

Name Type Default Description
width number Surface width in pixels
height number Surface height in pixels
format number natiny.surface.COLOR Pixel format of the colour texture
depth boolean true Give it a depth buffer

Formats

Constant Meaning
natiny.surface.COLOR Window-compatible BGRA8 color format
natiny.surface.RGBA8 Explicit RGBA8 channel order
natiny.surface.RGBA16F half float - normals, positions, anything past 1
natiny.surface.RGBA32F full float
natiny.surface.R32F one float channel, e.g. linear depth

Returns

Type Description
number Surface handle

Example

Lua
local scene = natiny.surface.create(1280, 720)

Notes

  • Requires an initialized graphics device and positive dimensions; Lua raises an error on failure.
  • COLOR matches the window-compatible BGRA8 layout; RGBA8 has explicit RGBA channel order. Floating-point formats preserve values outside 0..1.
  • The surface owns its color attachment and optional depth attachment.