From 2135613c4979eff398753eec9b0513160b8ffeb7 Mon Sep 17 00:00:00 2001 From: nothke Date: Tue, 11 Jun 2024 01:17:51 +0200 Subject: [PATCH] Cleanup --- build.zig | 21 --------------------- build.zig.zon | 39 --------------------------------------- src/main.zig | 13 ++++--------- 3 files changed, 4 insertions(+), 69 deletions(-) diff --git a/build.zig b/build.zig index 76972ca..0230034 100644 --- a/build.zig +++ b/build.zig @@ -1,8 +1,5 @@ const std = @import("std"); -// Although this function looks imperative, note that its job is to -// declaratively construct a build graph that will be executed by an external -// runner. pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); @@ -18,31 +15,16 @@ pub fn build(b: *std.Build) void { exe.root_module.addImport("sokol", dep_sokol.module("sokol")); - // This declares intent for the executable to be installed into the - // standard location when the user invokes the "install" step (the default - // step when running `zig build`). b.installArtifact(exe); - // This *creates* a Run step in the build graph, to be executed when another - // step is evaluated that depends on it. The next line below will establish - // such a dependency. const run_cmd = b.addRunArtifact(exe); - // By making the run step depend on the install step, it will be run from the - // installation directory rather than directly from within the cache directory. - // This is not necessary, however, if the application depends on other installed - // files, this ensures they will be present and in the expected location. run_cmd.step.dependOn(b.getInstallStep()); - // This allows the user to pass arguments to the application in the build - // command itself, like this: `zig build run -- arg1 arg2 etc` if (b.args) |args| { run_cmd.addArgs(args); } - // This creates a build step. It will be visible in the `zig build --help` menu, - // and can be selected like this: `zig build run` - // This will evaluate the `run` step rather than the default, which is "install". const run_step = b.step("run", "Run the app"); run_step.dependOn(&run_cmd.step); @@ -54,9 +36,6 @@ pub fn build(b: *std.Build) void { const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); - // Similar to creating the run step earlier, this exposes a `test` step to - // the `zig build --help` menu, providing a way for the user to request - // running the unit tests. const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_exe_unit_tests.step); } diff --git a/build.zig.zon b/build.zig.zon index 069b37b..8090a16 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -8,50 +8,11 @@ .url = "git+https://github.com/floooh/sokol-zig.git#d3e21f76498213d6d58179065756f5f2ed9b90cf", .hash = "122052a192829b377c637ce242ee8c9121e03d8cd10c889758dc6fb176368de7d67b", }, - // See `zig fetch --save ` for a command-line interface for adding dependencies. - //.example = .{ - // // When updating this field to a new URL, be sure to delete the corresponding - // // `hash`, otherwise you are communicating that you expect to find the old hash at - // // the new URL. - // .url = "https://example.com/foo.tar.gz", - // - // // This is computed from the file contents of the directory of files that is - // // obtained after fetching `url` and applying the inclusion rules given by - // // `paths`. - // // - // // This field is the source of truth; packages do not come from a `url`; they - // // come from a `hash`. `url` is just one of many possible mirrors for how to - // // obtain a package matching this `hash`. - // // - // // Uses the [multihash](https://multiformats.io/multihash/) format. - // .hash = "...", - // - // // When this is provided, the package is found in a directory relative to the - // // build root. In this case the package's hash is irrelevant and therefore not - // // computed. This field and `url` are mutually exclusive. - // .path = "foo", - - // // When this is set to `true`, a package is declared to be lazily - // // fetched. This makes the dependency only get fetched if it is - // // actually used. - // .lazy = false, - //}, }, - // Specifies the set of files and directories that are included in this package. - // Only files and directories listed here are included in the `hash` that - // is computed for this package. Only files listed here will remain on disk - // when using the zig package manager. As a rule of thumb, one should list - // files required for compilation plus any license(s). - // Paths are relative to the build root. Use the empty string (`""`) to refer to - // the build root itself. - // A directory listed here means that all files within, recursively, are included. .paths = .{ "build.zig", "build.zig.zon", "src", - // For example... - //"LICENSE", - //"README.md", }, } diff --git a/src/main.zig b/src/main.zig index 3bdb8d6..ffe0391 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,11 +3,6 @@ const std = @import("std"); const sokol = @import("sokol"); const sg = sokol.gfx; -const state = struct { - var bind: sg.Bindings = .{}; - var pip: sg.Pipeline = .{}; -}; - var pass_action: sg.PassAction = .{}; export fn init() void { @@ -27,13 +22,13 @@ export fn init() void { } fn timef() f32 { - return @as(f32, @floatCast(sokol.time.sec(sokol.time.now()))); + return @floatCast(sokol.time.sec(sokol.time.now())); } export fn frame() void { - //std.log.info("{}", .{sokol.time.now()}); - - pass_action.colors[0].clear_value.g = @abs(@sin(timef())); + const col = &pass_action.colors[0].clear_value; + col.g = @abs(@sin(timef())); + col.r = @abs(@cos(timef())); sg.beginPass(.{ .action = pass_action, .swapchain = sokol.glue.swapchain() }); sg.endPass();