render: add depth buffer
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m13s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 8m13s
This commit is contained in:
parent
77c717f90b
commit
650b61e3ae
4 changed files with 61 additions and 21 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -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>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue