Skip to content

Latest commit

 

History

History
41 lines (36 loc) · 1.14 KB

README.md

File metadata and controls

41 lines (36 loc) · 1.14 KB

A solo example (original from nanovg-zig/examples/example_blur.zig) using nanovg-zig.

Demo build.zig (zig 0.14.0-dev.2218) on how to use dependency and its resouces:

  1. nanovg module
const nanovg = b.dependency("nanovg.zig", .{
    .target = target,
    .optimize = optimize,
});
exe.root_module.addImport("nanovg", nanovg.module("nanovg"));
  1. examples/perf.zig
const perf = b.addModule("perf.zig", .{
    .root_source_file = nanovg.path("examples/perf.zig"),
});
perf.addImport("nanovg", nanovg.module("nanovg"));
exe.root_module.addImport("perf.zig", perf);
  1. font or other assets of examples/
const assets_mapping = [_][]const u8{
    "examples/Roboto-Regular.ttf", "assets/fonts/Roboto-Regular.ttf",
};
const imax = assets_mapping.len - 1;
var i: usize = 0;
while (i < imax) : (i += 2) {
    exe.root_module.addAnonymousImport(assets_mapping[i + 1], .{
        .root_source_file = nanovg.path(assets_mapping[i]),
    });
}
  1. lib/gl2
exe.addIncludePath(nanovg.path("lib/gl2/include"));
exe.addCSourceFile(.{ .file = nanovg.path("lib/gl2/src/glad.c"), .flags = &.{} });