lol
This commit is contained in:
parent
a39b31dc33
commit
92dc4e3885
2 changed files with 13 additions and 5 deletions
|
@ -18,6 +18,16 @@ impl WindowData {
|
||||||
pub fn resize(&mut self, width: u32, height: u32, factor: u32, window: &Window) {
|
pub fn resize(&mut self, width: u32, height: u32, factor: u32, window: &Window) {
|
||||||
self.pixels = new_pixels(width, height, factor, window);
|
self.pixels = new_pixels(width, height, factor, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_frame(&mut self, buffer: &[[u8; 4]]) {
|
||||||
|
self.pixels
|
||||||
|
.frame_mut()
|
||||||
|
.copy_from_slice(bytemuck::cast_slice(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&mut self) {
|
||||||
|
self.pixels.render().unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_pixels(width: u32, height: u32, scaling: u32, window: &Window) -> Pixels {
|
fn new_pixels(width: u32, height: u32, scaling: u32, window: &Window) -> Pixels {
|
||||||
|
|
|
@ -75,8 +75,8 @@ impl WindowManager {
|
||||||
}
|
}
|
||||||
Event::RedrawRequested(window_id) => {
|
Event::RedrawRequested(window_id) => {
|
||||||
if let Some(w) = self.windows.get(&window_id) {
|
if let Some(w) = self.windows.get(&window_id) {
|
||||||
if let Ok(data) = w.lock() {
|
if let Ok(mut data) = w.lock() {
|
||||||
data.pixels.render().unwrap();
|
data.render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,9 +162,7 @@ impl Renderer<[u8; 4]> for WindowRenderer {
|
||||||
|
|
||||||
fn display(&mut self, buffer: &[[u8; 4]]) {
|
fn display(&mut self, buffer: &[[u8; 4]]) {
|
||||||
if let Ok(mut data) = self.data.lock() {
|
if let Ok(mut data) = self.data.lock() {
|
||||||
data.pixels
|
data.new_frame(buffer);
|
||||||
.frame_mut()
|
|
||||||
.copy_from_slice(bytemuck::cast_slice(buffer));
|
|
||||||
}
|
}
|
||||||
self.window.request_redraw();
|
self.window.request_redraw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue