commit cc8263b14182c4c3c2d321d529d64941a3a8a348 Author: kayomn Date: Thu Jul 25 22:47:15 2024 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3389c86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.zig-cache/ +zig-out/ diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..e46ab55 --- /dev/null +++ b/build.zig @@ -0,0 +1,34 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const ona_dependency = b.dependency("ona", .{ + .target = target, + .optimize = optimize, + }); + + const app = b.addExecutable(.{ + .name = "ona-template", + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + app.root_module.addImport("ona", ona_dependency.module("ona")); + app.root_module.addImport("gfx", ona_dependency.module("gfx")); + app.root_module.addImport("hid", ona_dependency.module("hid")); + b.installArtifact(app); + + const run_cmd = b.addRunArtifact(app); + + run_cmd.step.dependOn(b.getInstallStep()); + + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); +} diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..d900759 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,16 @@ +.{ + .name = "ona-template", + .version = "0.0.0", + + .dependencies = .{ + .ona = .{ .path = "../ona" }, + }, + + .paths = .{ + "build.zig", + "build.zig.zon", + "src", + "license", + "readme.md", + }, +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7b30be8 --- /dev/null +++ b/readme.md @@ -0,0 +1,9 @@ +# Ona Template + +A template project for working with Ona. + +This template is also built as part of the continuous integration pipeline for Ona itself, so it should always be up-to-date with the `main` branch. + +**Note** that consuming Ona as a package requires it be downloaded manually, either through the releases page or by cloning, and referencing as a local dependency. This is due to the repository using Git submodules to reference third-party code. + +This project assumes Ona is located in the same parent directory as it is, but this can changed by editing the `path` property of the Ona dependency in your `build.zig.zon` file. diff --git a/src/main.zig b/src/main.zig new file mode 100644 index 0000000..6d9923c --- /dev/null +++ b/src/main.zig @@ -0,0 +1,21 @@ +const gfx = @import("gfx"); + +const hid = @import("hid"); + +const ona = @import("ona"); + +pub const main = ona.App.setup + .with_module(gfx) + .with_module(hid) + .with_system(.render, ona.system_fn(render), .{ .label = "Hello Ona" }).build(); + +pub fn render(commands: gfx.Commands, display: ona.Read(gfx.Display)) !void { + try commands.draw_texture(.{ + .texture = .default, + + .transform = gfx.Transform2D.from_simplified(.{ + .scale = @splat(256), + .translation = .{ @floatFromInt(display.state.width / 2), @floatFromInt(display.state.height / 2) }, + }), + }); +}