depth buffer

This commit is contained in:
2019-07-27 00:13:20 +02:00
parent 96afb5a14b
commit 48418b88cb
4 changed files with 73 additions and 43 deletions

View File

@@ -4,7 +4,6 @@ use std::iter::FromIterator;
use cgmath::{Matrix4, Rad, Point3, Vector3, Deg};
mod vulkan;
use vulkan::vs::ty::PushConstants;
const PRINT_KEYBOARD_INPUT: bool = false;
@@ -24,7 +23,7 @@ impl Game for TestGame {
let mut proj = cgmath::perspective(
Rad::from(Deg(45.0)),
game_data.aspect_ratio,
game_data.dimensions[0] as f32 / game_data.dimensions[1] as f32,
0.1,
10.0
);
@@ -34,9 +33,11 @@ impl Game for TestGame {
game_data.push_constants.model = model.into();
game_data.push_constants.view = view.into();
game_data.push_constants.projection = proj.into();
game_data.line_push_constants.view = view.into();
game_data.line_push_constants.projection = proj.into();
}
fn on_window_event(self: &mut Self, game_data: &mut GameData, event: &Event) -> bool {
fn on_window_event(self: &mut Self, game_data: &mut GameData, event: &Event) {
match event {
Event::WindowEvent { event: WindowEvent::KeyboardInput { device_id, input }, .. } => {
if PRINT_KEYBOARD_INPUT {
@@ -61,7 +62,6 @@ impl Game for TestGame {
}
_ => {}
}
return false;
}
}
@@ -69,10 +69,13 @@ fn main() {
let mut game = TestGame {};
vulkan::init(
"models/box.obj",
vec![
LinePoint { position: [-0.9, 1., 0.] },
LinePoint { position: [0.9, 0., 0.] },
],
(-10..10)
.flat_map(|it| vec![
LinePoint { position: [it as f32, -10., 0.] },
LinePoint { position: [it as f32, 10., 0.] },
LinePoint { position: [-10., it as f32, 0.] },
LinePoint { position: [10., it as f32, 0.] },
]).collect(),
&mut game
);
}