From 592e8a658d80c2720a940953d6c4decd656d444c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 12 Jun 2019 21:58:41 +0300 Subject: [PATCH] Add a builtin resource collection for storing necessary data --- Build | 11 +++++++++++ source/resources.cpp | 30 ++++++++++++++++++++++++++++++ source/resources.h | 6 ++++++ 3 files changed, 47 insertions(+) diff --git a/Build b/Build index e0d8537..6fd553a 100644 --- a/Build +++ b/Build @@ -10,9 +10,20 @@ package "mspdemoscene" require "mspgl"; require "mspal"; + generate "RES" + { + in_suffix ".glsl"; + out_suffix ".cpp"; + command "mspdatatool"; + arguments "-i" "-n" "Msp::DemoScene"; + out_argument "-o"; + processing_unit DIRECTORY; + }; + library "mspdemoscene" { source "source"; + source "data"; install true; install_map { diff --git a/source/resources.cpp b/source/resources.cpp index 1742f06..f44d8c1 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "resources.h" @@ -7,6 +8,13 @@ using namespace std; namespace Msp { namespace DemoScene { +void init_data(DataFile::BuiltinSource &); + +Resources::Resources() +{ + add_source(get_builtin_source()); +} + Resources::Resources(const string &pack_name): ui_font(0), ui_text_technique(0) @@ -27,6 +35,28 @@ Resources::Resources(const string &pack_name): pack_source.add_pack_file(pack_name); add_source(pack_source); } + + add_source(get_builtin_source()); +} + +const DataFile::CollectionSource &Resources::get_builtin_source() +{ + static DataFile::BuiltinSource builtin_src; + bool init_done = false; + + if(!init_done) + { + init_data(builtin_src); + init_done = true; + } + + return builtin_src; +} + +Resources &Resources::get_builtins() +{ + static Resources builtins; + return builtins; } const GL::Font &Resources::get_ui_font() const diff --git a/source/resources.h b/source/resources.h index bb86933..fc7e7d2 100644 --- a/source/resources.h +++ b/source/resources.h @@ -19,9 +19,15 @@ private: const Msp::GL::Font *ui_font; const Msp::GL::Technique *ui_text_technique; + Resources(); public: Resources(const std::string &); +private: + static const DataFile::CollectionSource &get_builtin_source(); +public: + static Resources &get_builtins(); + const Msp::GL::Font &get_ui_font() const; const Msp::GL::Technique &get_ui_text_technique() const; void set_ui_text_resources(const std::string &, const std::string &); -- 2.45.2