From 1902248ef8ae9d3e8abb7dba5a99be1c7cc02bfa Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Mon, 12 Jul 2021 23:54:03 +0100 Subject: [PATCH] start of asset loading --- demo/data/res/.gitignore | 2 ++ demo/data/res/demo/manifest.yml | 3 +++ demo/main.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 demo/data/res/.gitignore create mode 100644 demo/data/res/demo/manifest.yml diff --git a/demo/data/res/.gitignore b/demo/data/res/.gitignore new file mode 100644 index 0000000..2cd840c --- /dev/null +++ b/demo/data/res/.gitignore @@ -0,0 +1,2 @@ +# non-free (non-CC) assets for testing +nonfree/ diff --git a/demo/data/res/demo/manifest.yml b/demo/data/res/demo/manifest.yml new file mode 100644 index 0000000..acfdedb --- /dev/null +++ b/demo/data/res/demo/manifest.yml @@ -0,0 +1,3 @@ +--- +id: "com.fossgalaxy.games.demo" +name: "Demo Content Pack" diff --git a/demo/main.cpp b/demo/main.cpp index cece584..4c73b34 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -1,6 +1,6 @@ +#include <filesystem> #include <iostream> - #include <fggl/gfx/window.hpp> #include <fggl/gfx/ogl.hpp> #include <fggl/gfx/renderer.hpp> @@ -10,6 +10,30 @@ #include <fggl/debug/debug.h> #include <fggl/data/storage.hpp> +// prototype of resource discovery +void discover(std::filesystem::path base) { + + std::vector< std::filesystem::path > contentPacks; + for ( auto& item : std::filesystem::directory_iterator(base) ) { + + // content pack detection + if ( std::filesystem::is_directory( item ) ) { + auto manifest = item.path() / "manifest.yml"; + if ( std::filesystem::exists( manifest ) ) { + contentPacks.push_back( item.path() ); + } + } + + } + + // what did we find? + std::cerr << "found pack(s): " << std::endl; + for ( auto& pack : contentPacks ) { + std::cerr << pack << std::endl; + } + +} + int main(int argc, char* argv[]) { fggl::gfx::Context ctx; @@ -21,10 +45,14 @@ int main(int argc, char* argv[]) { fggl::gfx::Graphics ogl(win); fggl::gfx::MeshRenderer meshRenderer; + // debug layer fggl::debug::DebugUI debug(win); debug.visible(false); + // storage API fggl::data::Storage storage; + discover( storage.resolvePath(fggl::data::Data, "res") ); + fggl::gfx::ShaderCache cache(storage); fggl::gfx::ShaderConfig config; -- GitLab