diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..92794c2 Binary files /dev/null and b/.DS_Store differ diff --git a/build.zig b/build.zig index b7b36a2..d6c3b00 100644 --- a/build.zig +++ b/build.zig @@ -37,6 +37,7 @@ pub fn build(b: *std.Build) void { }); simdjson_lib.addIncludePath(simdjson_dep.path("singleheader")); b.installArtifact(simdjson_lib); + b.installDirectory(.{ .source_dir = simdjson_dep.path("include"), .install_dir = .{ .custom = "include" }, .install_subdir = "." }); const fastgltf_lib: *std.Build.Step.Compile = switch (preferred_link_mode) { inline else => |x| switch (x) { @@ -68,12 +69,20 @@ pub fn build(b: *std.Build) void { fastgltf_lib.root_module.addCMacro("FASTGLTF_DISABLE_CUSTOM_MEMORY_POOL", if (disable_custom_memory_pool) "1" else "0"); fastgltf_lib.root_module.addCMacro("FASTGLTF_USE_64BIT_FLOAT", if (use_64bit_float) "1" else "0"); b.installArtifact(fastgltf_lib); + b.installDirectory(.{ .source_dir = fastgltf_dep.path("include"), .install_dir = .{ .custom = "include" }, .install_subdir = "." }); const example = b.addExecutable(.{ .name = "fastgltf-example", .target = target, .optimize = optimize, }); + example.linkLibCpp(); + example.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ b.install_path, "include" }) }); example.linkLibrary(fastgltf_lib); - b.installAr + example.addCSourceFile(.{ .file = b.path("example/main.cpp") }); + + const run_artifact = b.addRunArtifact(example); + const run = b.step("run", "Run example"); + run.dependOn(&run_artifact.step); + // b.installArtifact(example); } diff --git a/example/Avocado.glb b/example/Avocado.glb new file mode 100644 index 0000000..006b79c Binary files /dev/null and b/example/Avocado.glb differ diff --git a/example/main.cpp b/example/main.cpp index 9b65bc5..953d3fa 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -1,7 +1,9 @@ +#include #include #include +#include -bool load(std::filesystem::path path) { +static bool load(std::filesystem::path path) { // Creates a Parser instance. Optimally, you should reuse this across loads, // but don't use it across threads. To enable extensions, you have to pass // them into the parser's constructor. @@ -34,6 +36,7 @@ bool load(std::filesystem::path path) { // The glTF 2.0 asset is now ready to be used. Simply call asset.get(), // asset.get_if() or asset-> to get a direct reference to the Asset class. You // can then access the glTF data structures, like, for example, with buffers: + printf("%d\n", asset->buffers.size()); for (auto &buffer : asset->buffers) { // Process the buffers. } @@ -48,4 +51,4 @@ bool load(std::filesystem::path path) { return true; } -int main() { return 0; } +int main() { return !load("example/Avocado.glb"); }