Giter Club home page Giter Club logo

bevy_pixels's Introduction

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

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.

bevy_pixels's People

Contributors

dtcristo avatar parasyte avatar

Stargazers

Marcos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.