diff --git a/shaders/triangle.vert b/shaders/triangle.vert index 9517f3a..1eca8d6 100644 --- a/shaders/triangle.vert +++ b/shaders/triangle.vert @@ -14,6 +14,8 @@ layout(location = 0) out vec2 tex_coords; layout(push_constant) uniform PushConstants { mat4 model; + mat4 view; + mat4 projection; } push; out gl_PerVertex { @@ -21,6 +23,6 @@ out gl_PerVertex { }; void main() { - gl_Position = ubo.projection * ubo.view * push.model * vec4(position, 1.0); + gl_Position = push.projection * push.view * push.model * vec4(position, 1.0); tex_coords = uv; } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index cb1f688..76aa79a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,6 +68,8 @@ impl Game for TestGame { renderer.game_data.line_push_constants.view = view.into(); renderer.game_data.line_push_constants.projection = proj.into(); + renderer.game_data.push_constants.view = view.into(); + renderer.game_data.push_constants.projection = proj.into(); self.input.frame_end(); diff --git a/src/vulkan.rs b/src/vulkan.rs index 79624f3..1c162ba 100644 --- a/src/vulkan.rs +++ b/src/vulkan.rs @@ -32,7 +32,7 @@ use vs::ty::PushConstants; use crate::mesh::CPUMesh; -const VALIDATION_LAYERS: &[&str] = &[ +const VALIDATION_LAYERS: &[&str] = &[ "VK_LAYER_LUNARG_standard_validation" ]; @@ -111,6 +111,8 @@ impl VulkanRenderer { let mut data = GameData { push_constants: PushConstants { model: Matrix4::identity().into(), + view: Matrix4::identity().into(), + projection: Matrix4::identity().into(), }, line_push_constants: LinePushConstants { model: Matrix4::identity().into(), @@ -469,6 +471,7 @@ pub fn start_event_loop(mut renderer: VulkanRenderer, mut game: Box, e let ubo = game.update(&mut renderer); event_loop.run(move |event, _, control_flow| { + game.on_window_event(&event); match event { Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => { *control_flow = ControlFlow::Exit;