gpu_paint API

← gpu_paint · version 0.2.1

9 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.

pub struct Sprites { texture: gpu::Texture, const cols: integer, const rows: integer, scene: gpu::Pipeline, values: gpu::Block, quad: gpu::Buffer }

A picture on the GPU cut into a grid of cols x rows sprites; sprite 0 is the top left, counting along the rows.

pub fn sprites( dev: const gpu::Device, pixels: const vector<u32>, width: integer, height: integer, cols: integer, rows: integer, into: integer ) -> Sprites?

Upload pixels (0xAARRGGBB, width to a row, the top row first) as a sheet of cols x rows cells, sampled between its pixels (sheet.texture.nearest(true) for pixel art). into is what draw will draw into (gpu::INTO_WINDOW, …). Null on a device whose backend this library has no shader source for.

pub fn draw(self: Sprites, dev: gpu::Device, mvp: const vector<float>, index: integer)

Draw sprite index through mvp, which maps the unit quad onto the target (16 floats, column-major), in the pass in progress: tested against the depth drawn so far.

pub struct Painter { blend: boolean, flat: gpu::Pipeline, flat_over: gpu::Pipeline, whole: gpu::Pipeline, whole_over: gpu::Pipeline, cell: gpu::Pipeline, cell_over: gpu::Pipeline, flat_values: gpu::Block, image_values: gpu::Block, cell_values: gpu::Block, quad: gpu::Buffer, proj: vector<float> }

Pipelines and a unit quad for drawing at pixel positions.

pub fn painter(dev: const gpu::Device, into: integer) -> Painter?

A painter for passes that draw into into (gpu::INTO_WINDOW, gpu::INTO_COLOUR, …), sized to the device's window. Null on a device whose backend this library has no shader source for.

pub fn resize(self: Painter, width: integer, height: integer)

Draw for a target of width x height pixels from now on: after the window was resized, or for a pass into a texture of another size.

pub fn rect( self: Painter, dev: gpu::Device, x: float, y: float, w: float, h: float, r: float, g: float, b: float, a: float )

A filled rectangle at (x, y) of w x h pixels, channels 0.0-1.0.

pub fn image(self: Painter, dev: gpu::Device, t: const gpu::Texture, x: float, y: float, w: float, h: float)

A texture stretched over (x, y) of w x h pixels; fully transparent pixels are not drawn.

pub fn sprite( self: Painter, dev: gpu::Device, sheet: const Sprites, x: float, y: float, w: float, h: float, index: integer )

Sprite index of sheet over (x, y) of w x h pixels.