Prepare to draw mesh

This commit is contained in:
Hanno Braun 2024-10-30 02:50:38 +01:00
parent 63e1f15e7b
commit 513dcdc590
2 changed files with 7 additions and 3 deletions

View File

@ -10,10 +10,11 @@ use winit::{
use crate::{mesh::Mesh, render::Renderer};
pub fn run(_: Mesh) -> anyhow::Result<()> {
pub fn run(mesh: Mesh) -> anyhow::Result<()> {
let event_loop = EventLoop::new()?;
let mut app = App {
mesh,
window: None,
renderer: None,
};
@ -23,6 +24,7 @@ pub fn run(_: Mesh) -> anyhow::Result<()> {
}
struct App {
mesh: Mesh,
window: Option<Arc<Window>>,
renderer: Option<Renderer>,
}
@ -67,7 +69,7 @@ impl ApplicationHandler for App {
event_loop.exit();
}
WindowEvent::RedrawRequested => {
renderer.render();
renderer.render(&self.mesh);
}
_ => {}
}

View File

@ -3,6 +3,8 @@ use std::sync::Arc;
use anyhow::anyhow;
use winit::window::Window;
use crate::mesh::Mesh;
pub struct Renderer {
pub surface: wgpu::Surface<'static>,
pub device: wgpu::Device,
@ -37,7 +39,7 @@ impl Renderer {
})
}
pub fn render(&self) {
pub fn render(&self, _: &Mesh) {
let frame = self.surface.get_current_texture().unwrap();
let view = frame
.texture