examples: texture-light: zig fmt

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-04-21 04:23:32 -07:00 committed by Stephen Gutekanst
parent 9ec8553cf8
commit 417ec654df

View file

@ -96,9 +96,7 @@ fn frame(app: *App, params: *FrameParams) !void {
if (params.keys & FrameParams.down != 0)
params.camera.eye -= fwd * speed;
if (params.keys & FrameParams.right != 0) params.camera.eye += right * speed
else if (params.keys & FrameParams.left != 0) params.camera.eye -= right * speed
else params.camera.eye += right * (speed * @Vector(4, f32){0.5, 0.5, 0.5, 0.5});
if (params.keys & FrameParams.right != 0) params.camera.eye += right * speed else if (params.keys & FrameParams.left != 0) params.camera.eye -= right * speed else params.camera.eye += right * (speed * @Vector(4, f32){ 0.5, 0.5, 0.5, 0.5 });
params.camera.update(params.queue);
@ -120,9 +118,7 @@ fn frame(app: *App, params: *FrameParams) !void {
};
const render_pass_descriptor = gpu.RenderPassEncoder.Descriptor{
.color_attachments = &.{
color_attachment
},
.color_attachments = &.{color_attachment},
.depth_stencil_attachment = &.{
.view = params.depth.view,
.depth_load_op = .clear,
@ -617,7 +613,9 @@ const Texture = struct {
});
device.getQueue().writeTexture(
&gpu.ImageCopyTexture{ .texture = texture, },
&gpu.ImageCopyTexture{
.texture = texture,
},
data,
&gpu.Texture.DataLayout{
.bytes_per_row = 4 * width,
@ -890,20 +888,35 @@ fn keyCallback(window: glfw.Window, key: glfw.Key, scancode: i32, action: glfw.A
if (action == .press) {
switch (key) {
.q, .escape, .space => window.setShouldClose(true),
.w, .up => { global_params.keys |= FrameParams.up; },
.s, .down => { global_params.keys |= FrameParams.down; },
.a, .left => { global_params.keys |= FrameParams.left; },
.d, .right => { global_params.keys |= FrameParams.right; },
.w, .up => {
global_params.keys |= FrameParams.up;
},
.s, .down => {
global_params.keys |= FrameParams.down;
},
.a, .left => {
global_params.keys |= FrameParams.left;
},
.d, .right => {
global_params.keys |= FrameParams.right;
},
else => {},
}
} else if (action == .release) {
switch (key) {
.w, .up => { global_params.keys &= ~FrameParams.up; },
.s, .down => { global_params.keys &= ~FrameParams.down; },
.a, .left => { global_params.keys &= ~FrameParams.left; },
.d, .right => { global_params.keys &= ~FrameParams.right; },
.w, .up => {
global_params.keys &= ~FrameParams.up;
},
.s, .down => {
global_params.keys &= ~FrameParams.down;
},
.a, .left => {
global_params.keys &= ~FrameParams.left;
},
.d, .right => {
global_params.keys &= ~FrameParams.right;
},
else => {},
}
}
}