render: add depth buffer
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m13s

This commit is contained in:
Florian RICHER 2025-05-29 17:44:00 +02:00
parent 77c717f90b
commit 650b61e3ae
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
4 changed files with 61 additions and 21 deletions

View file

@ -130,26 +130,24 @@ impl ApplicationHandler for App {
&self.input_manager,
&self.timer,
));
self.scene_manager.load_scene_if_not_loaded(&scene_context);
self.scene_manager
.load_scene_if_not_loaded(&scene_context)
.unwrap();
if let Some(scene) = self.scene_manager.current_scene_mut() {
if let Err(e) = scene.update(&scene_context) {
log::error!("Error updating scene: {}", e);
}
scene.update(&scene_context).unwrap();
let acquire_future = renderer.acquire(None, |_| {}).unwrap();
let acquire_future = scene.render(
&renderer.swapchain_image_view(),
acquire_future,
&scene_context,
gui,
);
match acquire_future {
Ok(future) => renderer.present(future, true),
Err(e) => {
log::error!("Error rendering scene: {}", e);
}
}
let acquire_future = scene
.render(
&renderer.swapchain_image_view(),
acquire_future,
&scene_context,
gui,
)
.unwrap();
renderer.present(acquire_future, true);
}
}
_ => {}

View file

@ -1,3 +1,5 @@
use std::error::Error;
use super::{Scene, SceneContext};
pub struct SceneManager {
@ -11,14 +13,16 @@ impl SceneManager {
}
}
pub fn load_scene_if_not_loaded(&mut self, scene_context: &SceneContext) {
pub fn load_scene_if_not_loaded(
&mut self,
scene_context: &SceneContext,
) -> Result<(), Box<dyn Error>> {
if let Some(current_scene) = self.current_scene.as_mut() {
if !current_scene.loaded() {
if let Err(e) = current_scene.load(scene_context) {
log::error!("Error loading scene: {}", e);
}
current_scene.load(scene_context)?;
}
}
Ok(())
}
pub fn load_scene(&mut self, scene: Box<dyn Scene>) {