Crate pixels

Source
Expand description

A tiny library providing a GPU-powered pixel buffer.

Pixels represents a 2D pixel buffer with an explicit image resolution, making it ideal for prototyping simple pixel-based games, animations, and emulators. The pixel buffer is rendered entirely on the GPU, allowing developers to easily incorporate special effects with shaders and a customizable pipeline.

The GPU interface is offered by wgpu, and is re-exported for your convenience. Use a windowing framework or context manager of your choice; winit is a good place to start. Any windowing framework that uses raw-window-handle will work.

§Environment variables

Pixels will default to selecting the most powerful GPU and most modern graphics API available on the system, and these choices can be overridden with environment variables. These are the same vars supported by the wgpu examples.

  • WGPU_BACKEND: Select the backend (aka graphics API).
    • Supported values: vulkan, metal, dx11, dx12, gl, webgpu
    • The default depends on capabilities of the host system, with vulkan being preferred on Linux and Windows, and metal preferred on macOS.
  • WGPU_ADAPTER_NAME: Select an adapter (aka GPU) with substring matching.
    • E.g. 1080 will match NVIDIA GeForce 1080ti
  • WGPU_POWER_PREF: Select an adapter (aka GPU) that meets the given power profile.
    • Supported values: low, high
    • The default is low. I.e. an integrated GPU will be preferred over a discrete GPU.

Note that WGPU_ADAPTER_NAME and WGPU_POWER_PREF are mutually exclusive and that WGPU_ADAPTER_NAME takes precedence.

Re-exports§

pub use raw_window_handle;
pub use wgpu;

Structs§

Pixels
Represents a 2D pixel buffer with an explicit image resolution.
PixelsBuilder
A builder to help create customized pixel buffers.
PixelsContext
Provides the internal state for custom shaders.
ScalingRenderer
The default renderer that scales your frame to the screen size.
SurfaceTexture
A logical texture for a window surface.

Enums§

Error
All the ways in which creating a pixel buffer can fail.
TextureError
All the ways in which creating a texture can fail.

Functions§

check_texture_size
Compare the given size to the limits defined by device.