-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.rs
26 lines (22 loc) · 835 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use bevy::prelude::*;
use bevy_pixels::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, PixelsPlugin::default()))
.add_systems(Startup, setup)
.add_systems(Update, bevy::window::close_on_esc)
.add_systems(Draw, draw)
.run();
}
/// Spawn two more windows in addition to the primary window that comes by default.
fn setup(mut commands: Commands) {
commands.spawn((Window::default(), PixelsOptions::default()));
commands.spawn((Window::default(), PixelsOptions::default()));
}
/// Draw solid background to each window's buffer.
fn draw(mut wrapper_query: Query<&mut PixelsWrapper>) {
for mut wrapper in &mut wrapper_query {
let frame = wrapper.pixels.frame_mut();
frame.copy_from_slice(&[0x48, 0xb2, 0xe8, 0xff].repeat(frame.len() / 4));
}
}