ComLarsic / bevy_pixels

◼️▫️ Bevy plugin that uses Pixels (a tiny pixel buffer) for rendering

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bevy_pixels

Bevy plugin that uses Pixels (a tiny pixel buffer) for rendering

crates.io Bevy tracking

Usage

Add bevy and bevy_pixels to Cargo.toml. Be sure to disable bevy's render and bevy_wgpu features (with default-features = false) as they will conflict with rendering provided by bevy_pixels.

[dependencies]
bevy = { version = "0.8", default_features = false }
bevy_pixels = { git = "https://github.com/dtcristo/bevy_pixels" }

Add PixelsPlugin to your Bevy project.

use bevy::prelude::*;
use bevy_pixels::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugin(PixelsPlugin)
        .add_system(main_system)
        .run();
}

Use PixelsResource in your systems.

fn main_system(mut pixels_resource: ResMut<PixelsResource>) {
    // Get a mutable slice for the pixel buffer
    let frame: &mut [u8] = pixels_resource.pixels.get_frame_mut();

    // Fill frame with pixel data
    // ...
}

Bevy and Pixels version mapping

bevy_pixels bevy pixels
0.1 0.5 0.3
0.2 0.5 0.8
0.3-0.4 0.6 0.9
0.5 0.7 0.9

Examples

minimal

This example is based off minimal-winit example from the pixels project.

minimal example

Running examples natively

cargo run --release --example example_name

Running examples in browser

Install dependencies.

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli just miniserve

Build and serve example with just. See Justfile for more details.

just serve example_name

Open http://localhost:8080/ in your browser to run the example.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Todo

  • Add more configuration around how rendering is performed.
  • Add support for multiple windows.

About

◼️▫️ Bevy plugin that uses Pixels (a tiny pixel buffer) for rendering

License:Other


Languages

Language:Rust 100.0%