examples: texture-light: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9ec8553cf8
commit
417ec654df
1 changed files with 92 additions and 79 deletions
|
|
@ -96,9 +96,7 @@ fn frame(app: *App, params: *FrameParams) !void {
|
||||||
if (params.keys & FrameParams.down != 0)
|
if (params.keys & FrameParams.down != 0)
|
||||||
params.camera.eye -= fwd * speed;
|
params.camera.eye -= fwd * speed;
|
||||||
|
|
||||||
if (params.keys & FrameParams.right != 0) params.camera.eye += right * 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 });
|
||||||
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);
|
params.camera.update(params.queue);
|
||||||
|
|
||||||
|
|
@ -120,9 +118,7 @@ fn frame(app: *App, params: *FrameParams) !void {
|
||||||
};
|
};
|
||||||
|
|
||||||
const render_pass_descriptor = gpu.RenderPassEncoder.Descriptor{
|
const render_pass_descriptor = gpu.RenderPassEncoder.Descriptor{
|
||||||
.color_attachments = &.{
|
.color_attachments = &.{color_attachment},
|
||||||
color_attachment
|
|
||||||
},
|
|
||||||
.depth_stencil_attachment = &.{
|
.depth_stencil_attachment = &.{
|
||||||
.view = params.depth.view,
|
.view = params.depth.view,
|
||||||
.depth_load_op = .clear,
|
.depth_load_op = .clear,
|
||||||
|
|
@ -617,7 +613,9 @@ const Texture = struct {
|
||||||
});
|
});
|
||||||
|
|
||||||
device.getQueue().writeTexture(
|
device.getQueue().writeTexture(
|
||||||
&gpu.ImageCopyTexture{ .texture = texture, },
|
&gpu.ImageCopyTexture{
|
||||||
|
.texture = texture,
|
||||||
|
},
|
||||||
data,
|
data,
|
||||||
&gpu.Texture.DataLayout{
|
&gpu.Texture.DataLayout{
|
||||||
.bytes_per_row = 4 * width,
|
.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) {
|
if (action == .press) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
.q, .escape, .space => window.setShouldClose(true),
|
.q, .escape, .space => window.setShouldClose(true),
|
||||||
.w, .up => { global_params.keys |= FrameParams.up; },
|
.w, .up => {
|
||||||
.s, .down => { global_params.keys |= FrameParams.down; },
|
global_params.keys |= FrameParams.up;
|
||||||
.a, .left => { global_params.keys |= FrameParams.left; },
|
},
|
||||||
.d, .right => { global_params.keys |= FrameParams.right; },
|
.s, .down => {
|
||||||
|
global_params.keys |= FrameParams.down;
|
||||||
|
},
|
||||||
|
.a, .left => {
|
||||||
|
global_params.keys |= FrameParams.left;
|
||||||
|
},
|
||||||
|
.d, .right => {
|
||||||
|
global_params.keys |= FrameParams.right;
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
} else if (action == .release) {
|
} else if (action == .release) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
.w, .up => { global_params.keys &= ~FrameParams.up; },
|
.w, .up => {
|
||||||
.s, .down => { global_params.keys &= ~FrameParams.down; },
|
global_params.keys &= ~FrameParams.up;
|
||||||
.a, .left => { global_params.keys &= ~FrameParams.left; },
|
},
|
||||||
.d, .right => { global_params.keys &= ~FrameParams.right; },
|
.s, .down => {
|
||||||
|
global_params.keys &= ~FrameParams.down;
|
||||||
|
},
|
||||||
|
.a, .left => {
|
||||||
|
global_params.keys &= ~FrameParams.left;
|
||||||
|
},
|
||||||
|
.d, .right => {
|
||||||
|
global_params.keys &= ~FrameParams.right;
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue