render-zig

A 3D rendering engine written in Zig
git clone git://git.christianermann.dev/render-zig
Log | Files | Refs

commit 4fdfd4f1ecc51530bfe22e21e92c7890baf7a143
parent eb3897fc514820f47d2f70cc21b617572270cb71
Author: Christian Ermann <christianermann@gmail.com>
Date:   Wed, 10 Jul 2024 18:33:55 -0400

Update Zig and dependencies

Diffstat:
Mbuild.zig | 8++++----
Mbuild.zig.zon | 12++++++------
Msrc/camera.zig | 28++++++++++++++--------------
3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/build.zig b/build.zig @@ -20,7 +20,7 @@ pub fn build(b: *std.Build) void { .name = "render-zig", // In this case the main source file is merely a path, however, in more // complicated build scripts, this could be a generated file. - .root_source_file = .{ .path = "src/root.zig" }, + .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/root.zig" } }, .target = target, .optimize = optimize, }); @@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void { const exe = b.addExecutable(.{ .name = "render-zig", - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } }, .target = target, .optimize = optimize, }); @@ -90,7 +90,7 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. This only builds the test executable // but does not run it. const lib_unit_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/root.zig" }, + .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/root.zig" } }, .target = target, .optimize = optimize, }); @@ -98,7 +98,7 @@ pub fn build(b: *std.Build) void { const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); const exe_unit_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } }, .target = target, .optimize = optimize, }); diff --git a/build.zig.zon b/build.zig.zon @@ -16,18 +16,18 @@ // internet connectivity. .dependencies = .{ .@"mach-glfw" = .{ - .url = "https://pkg.machengine.org/mach-glfw/e57190c095097810980703aa26d4f0669a21dbab.tar.gz", - .hash = "12205a32c8e6ca23c68191b1e95405d2bd5f8e3055cba1c8ce0738d673ef49aef913", + .url = "https://pkg.machengine.org/mach-glfw/fb4ae48540454270ab969c8c645bbc6eff3c2dfb.tar.gz", + .hash = "12201ae68707aefe54ffb9d8c64721d4a2ac36186f8bd390e4f670033fec6737664a", .lazy = true, }, .@"mach-gpu" = .{ - .url = "https://pkg.machengine.org/mach-gpu/528dad0823dafeae5d474c88cc658b091bf2e605.tar.gz", - .hash = "1220fe2e555ca66741539bc0f97769b2513c5e609c968d27eb8997f577a1d195f048", + .url = "https://pkg.machengine.org/mach-gpu/4743eb5b485d97afdc0be8ad111aa1a3e5a884d8.tar.gz", + .hash = "12201c2574aa3edf9048dfbd5ec16de15a8345e9f27066e1d56e3e2ba35d32cba584", .lazy = true, }, .zigimg = .{ - .url = "https://github.com/zigimg/zigimg/archive/637974e2d31dcdbc33f1e9cc8ffb2e46abd2e215.tar.gz", - .hash = "122012026c3a65ff1d4acba3b3fe80785f7cee9c6b4cdaff7ed0fbf23b0a6c803989", + .url = "https://github.com/zigimg/zigimg/archive/2e7ce963028b65c1b020621d035a4e27251997ef.tar.gz", + .hash = "1220c65942a3932581f5c2ec3d8076e480e4b118378dcbf127c2b98041d2bcb46db6", .lazy = true, }, }, diff --git a/src/camera.zig b/src/camera.zig @@ -132,7 +132,7 @@ fn invLookAt(eye: f32x3, target: f32x3, up: f32x3, mat: *mat4) void { } fn perspective(fovy: f32, aspect: f32, near: f32, far: f32, mat: *mat4) void { - const tan_half_fov = @tan(std.math.degreesToRadians(f32, fovy * 0.5)); + const tan_half_fov = @tan(std.math.degreesToRadians(fovy * 0.5)); const a = 1.0 / (aspect * tan_half_fov); const b = 1.0 / tan_half_fov; const c = -(far + near) / (far - near); @@ -146,7 +146,7 @@ fn perspective(fovy: f32, aspect: f32, near: f32, far: f32, mat: *mat4) void { } fn invPerspective(fovy: f32, aspect: f32, near: f32, far: f32, mat: *mat4) void { - const tan_half_fov = @tan(std.math.degreesToRadians(f32, fovy * 0.5)); + const tan_half_fov = @tan(std.math.degreesToRadians(fovy * 0.5)); const a = aspect * tan_half_fov; const b = tan_half_fov; const c = (far + near) / (2 * far * near); @@ -160,10 +160,10 @@ fn invPerspective(fovy: f32, aspect: f32, near: f32, far: f32, mat: *mat4) void } pub fn view(self: *const Camera, mat: *mat4) void { - const cos_yaw = @cos(std.math.degreesToRadians(f32, self.yaw)); - const sin_yaw = @sin(std.math.degreesToRadians(f32, self.yaw)); - const cos_pitch = @cos(std.math.degreesToRadians(f32, self.pitch)); - const sin_pitch = @sin(std.math.degreesToRadians(f32, self.pitch)); + const cos_yaw = @cos(std.math.degreesToRadians(self.yaw)); + const sin_yaw = @sin(std.math.degreesToRadians(self.yaw)); + const cos_pitch = @cos(std.math.degreesToRadians(self.pitch)); + const sin_pitch = @sin(std.math.degreesToRadians(self.pitch)); const forward = f32x3_normalize( f32x3{ cos_yaw * cos_pitch, sin_pitch, sin_yaw * cos_pitch }, ); @@ -173,10 +173,10 @@ pub fn view(self: *const Camera, mat: *mat4) void { } pub fn invView(self: *const Camera, mat: *mat4) void { - const cos_yaw = @cos(std.math.degreesToRadians(f32, self.yaw)); - const sin_yaw = @sin(std.math.degreesToRadians(f32, self.yaw)); - const cos_pitch = @cos(std.math.degreesToRadians(f32, self.pitch)); - const sin_pitch = @sin(std.math.degreesToRadians(f32, self.pitch)); + const cos_yaw = @cos(std.math.degreesToRadians(self.yaw)); + const sin_yaw = @sin(std.math.degreesToRadians(self.yaw)); + const cos_pitch = @cos(std.math.degreesToRadians(self.pitch)); + const sin_pitch = @sin(std.math.degreesToRadians(self.pitch)); const forward = f32x3_normalize( f32x3{ cos_yaw * cos_pitch, sin_pitch, sin_yaw * cos_pitch }, ); @@ -224,10 +224,10 @@ pub fn update(self: *Camera, _: f32) void { self.pitch = -89; } - const cos_yaw = @cos(std.math.degreesToRadians(f32, self.yaw)); - const sin_yaw = @sin(std.math.degreesToRadians(f32, self.yaw)); - const cos_pitch = @cos(std.math.degreesToRadians(f32, self.pitch)); - const sin_pitch = @sin(std.math.degreesToRadians(f32, self.pitch)); + const cos_yaw = @cos(std.math.degreesToRadians(self.yaw)); + const sin_yaw = @sin(std.math.degreesToRadians(self.yaw)); + const cos_pitch = @cos(std.math.degreesToRadians(self.pitch)); + const sin_pitch = @sin(std.math.degreesToRadians(self.pitch)); const f = f32x3_normalize( f32x3{ cos_yaw * cos_pitch, sin_pitch, sin_yaw * cos_pitch }, );