Encodes render commands to binary format for the Rust command queue.
Binary format:
- 1 byte: command type
- N bytes: command-specific data
Command types:
- 0x01: Clear (4 bytes RGBA)
- 0x02: FillRect (16 bytes: x,y,w,h as u32 LE + 4 bytes RGBA)
- 0x03: DrawLine (16 bytes: x1,y1,x2,y2 as i32 LE + 4 bytes RGBA)
- 0x04: Blit (12 bytes: sprite_id as u64 LE + x,y as u32 LE)
- 0x05: Present (0 bytes)
- 0x06: Resize (8 bytes: width, height as u32 LE)
- 0x07: LoadSprite (16 bytes: id as u64 LE + w,h as u32 LE + pixel data)
- 0x08: RemoveSprite (8 bytes: id as u64 LE)
Summary
Functions
Convert a color to a 4-byte RGBA binary.
Encode a batch command containing multiple sub-commands.
Encode a blit command that draws a loaded sprite at the given position.
Encode a clear command that fills the entire surface with a solid color.
Encode a dispatch_compute command that runs a GPU compute shader.
Encode a draw_circle command.
Encode a draw_line command that draws a line between two points.
Encode a draw_round_rect command.
Encode a draw_triangle command.
Encode a fill_circle command.
Encode a fill_rect command that fills a rectangle with a solid color.
Encode a fill_round_rect command.
Encode a fill_triangle command.
Encode an image_blit command that draws a loaded image texture.
Encode a load_image command that uploads an image as a GPU texture.
Encode a load_shader command for hot-reloading shaders.
Encode a load_sprite command that uploads pixel data into the texture atlas.
Encode a present command that flushes the command queue and updates the GPU texture.
Encode a read_pixels command that reads back GPU texture data.
Encode a remove_image command that frees an image texture.
Encode a remove_sprite command that frees a sprite from the texture atlas.
Encode a reset_clip command.
Encode a resize command that changes the surface dimensions.
Encode a set_clip command.
Encode a set_uniform command for shader parameters.
Types
@type color() :: atom() | {0..255, 0..255, 0..255} | {0..255, 0..255, 0..255, 0..255}
Functions
Convert a color to a 4-byte RGBA binary.
Encode a batch command containing multiple sub-commands.
@spec encode_blit(non_neg_integer(), integer(), integer()) :: binary()
Encode a blit command that draws a loaded sprite at the given position.
Encode a clear command that fills the entire surface with a solid color.
@spec encode_dispatch_compute( String.t(), binary(), {non_neg_integer(), non_neg_integer(), non_neg_integer()} ) :: binary()
Encode a dispatch_compute command that runs a GPU compute shader.
@spec encode_draw_circle(integer(), integer(), non_neg_integer(), color()) :: binary()
Encode a draw_circle command.
Encode a draw_line command that draws a line between two points.
@spec encode_draw_round_rect( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), color() ) :: binary()
Encode a draw_round_rect command.
@spec encode_draw_triangle( integer(), integer(), integer(), integer(), integer(), integer(), color() ) :: binary()
Encode a draw_triangle command.
@spec encode_fill_circle(integer(), integer(), non_neg_integer(), color()) :: binary()
Encode a fill_circle command.
@spec encode_fill_rect( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), color() ) :: binary()
Encode a fill_rect command that fills a rectangle with a solid color.
@spec encode_fill_round_rect( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), color() ) :: binary()
Encode a fill_round_rect command.
@spec encode_fill_triangle( integer(), integer(), integer(), integer(), integer(), integer(), color() ) :: binary()
Encode a fill_triangle command.
@spec encode_image_blit( non_neg_integer(), integer(), integer(), non_neg_integer(), non_neg_integer() ) :: binary()
Encode an image_blit command that draws a loaded image texture.
@spec encode_load_image( non_neg_integer(), binary(), non_neg_integer(), non_neg_integer() ) :: binary()
Encode a load_image command that uploads an image as a GPU texture.
Encode a load_shader command for hot-reloading shaders.
@spec encode_load_sprite( non_neg_integer(), binary(), non_neg_integer(), non_neg_integer() ) :: binary()
Encode a load_sprite command that uploads pixel data into the texture atlas.
@spec encode_present() :: binary()
Encode a present command that flushes the command queue and updates the GPU texture.
@spec encode_read_pixels( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: binary()
Encode a read_pixels command that reads back GPU texture data.
@spec encode_remove_image(non_neg_integer()) :: binary()
Encode a remove_image command that frees an image texture.
@spec encode_remove_sprite(non_neg_integer()) :: binary()
Encode a remove_sprite command that frees a sprite from the texture atlas.
@spec encode_reset_clip() :: binary()
Encode a reset_clip command.
@spec encode_resize(non_neg_integer(), non_neg_integer()) :: binary()
Encode a resize command that changes the surface dimensions.
@spec encode_set_clip( non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), boolean() ) :: binary()
Encode a set_clip command.
Encode a set_uniform command for shader parameters.