Add simple movement for now
This commit is contained in:
parent
2e08987c83
commit
1bba633d99
2 changed files with 28 additions and 1 deletions
24
src/main.zig
24
src/main.zig
|
@ -69,8 +69,9 @@ pub fn main() !void {
|
|||
delta.start();
|
||||
|
||||
var angle: f32 = 0.0;
|
||||
const move_speed: f32 = 1000;
|
||||
|
||||
const model_handle = try vulkan_renderer.createMeshModel("tescoPiwo.obj");
|
||||
const model_handle = try vulkan_renderer.createMeshModel("teapot.obj");
|
||||
|
||||
mainLoop: while (true) {
|
||||
while (sdl.pollEvent()) |ev| {
|
||||
|
@ -85,6 +86,27 @@ pub fn main() !void {
|
|||
}
|
||||
}
|
||||
|
||||
const keystate = sdl.getKeyboardState();
|
||||
if (keystate.isPressed(sdl.Scancode.left_shift)) {
|
||||
const move = zm.translation(0.0, -move_speed * delta.delta_f32, 0.0);
|
||||
vulkan_renderer.updateCamera(move);
|
||||
} else if (keystate.isPressed(sdl.Scancode.left_control)) {
|
||||
const move = zm.translation(0.0, move_speed * delta.delta_f32, 0.0);
|
||||
vulkan_renderer.updateCamera(move);
|
||||
} else if (keystate.isPressed(sdl.Scancode.w)) {
|
||||
const move = zm.translation(0.0, 0.0, move_speed * delta.delta_f32);
|
||||
vulkan_renderer.updateCamera(move);
|
||||
} else if (keystate.isPressed(sdl.Scancode.s)) {
|
||||
const move = zm.translation(0.0, 0.0, -move_speed * delta.delta_f32);
|
||||
vulkan_renderer.updateCamera(move);
|
||||
} else if (keystate.isPressed(sdl.Scancode.a)) {
|
||||
const move = zm.translation(move_speed * delta.delta_f32, 0.0, 0.0);
|
||||
vulkan_renderer.updateCamera(move);
|
||||
} else if (keystate.isPressed(sdl.Scancode.d)) {
|
||||
const move = zm.translation(-move_speed * delta.delta_f32, 0.0, 0.0);
|
||||
vulkan_renderer.updateCamera(move);
|
||||
}
|
||||
|
||||
delta.tick();
|
||||
|
||||
angle += 200.0 * delta.delta_f32;
|
||||
|
|
|
@ -13,6 +13,7 @@ const QueueFamilyIndices = Utilities.QueueFamilyIndices;
|
|||
const SwapchainDetails = Utilities.SwapchainDetails;
|
||||
const SwapchainImage = Utilities.SwapchainImage;
|
||||
const Vertex = Utilities.Vertex;
|
||||
const Vector3 = Utilities.Vector3;
|
||||
|
||||
const Mesh = @import("Mesh.zig");
|
||||
const MeshModel = @import("MeshModel.zig");
|
||||
|
@ -195,6 +196,10 @@ pub const VulkanRenderer = struct {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn updateCamera(self: *Self, movement: zm.Mat) void {
|
||||
self.ubo_view_projection.view = zm.mul(self.ubo_view_projection.view, movement);
|
||||
}
|
||||
|
||||
pub fn draw(self: *Self) !void {
|
||||
// Wait for given fence to signal (open) from last draw before continuing
|
||||
_ = try self.device.waitForFences(
|
||||
|
|
Loading…
Reference in a new issue