Initial commit
This commit is contained in:
commit
cc8263b141
|
@ -0,0 +1,2 @@
|
|||
.zig-cache/
|
||||
zig-out/
|
|
@ -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);
|
||||
}
|
|
@ -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",
|
||||
},
|
||||
}
|
|
@ -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.
|
|
@ -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) },
|
||||
}),
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue