This commit is contained in:
Aandreba 2025-02-19 13:47:38 +01:00
parent a8f658b0cf
commit a2b5325676
4 changed files with 15 additions and 3 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View file

@ -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);
}

BIN
example/Avocado.glb Normal file

Binary file not shown.

View file

@ -1,7 +1,9 @@
#include <cstdio>
#include <fastgltf/core.hpp>
#include <fastgltf/types.hpp>
#include <filesystem>
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"); }