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.



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


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