X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=6a1c603c050766487a27995270c65d136f55ba91;hb=81c4024fb6acf37df702a803dc4efdf82a81525a;hp=40e44220a5b7de1b53011a14cb16d2ebe67ee6ee;hpb=131ac8ff2c06f94d40f4bf98d4a6ec0d113cdffc;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 40e4422..6a1c603 100644 --- a/source/resources.h +++ b/source/resources.h @@ -2,61 +2,57 @@ #define MSP_GLTK_RESOURCES_H_ #include +#include +#include +#include #include -#include +#include +#include +#include #include "graphic.h" +#include "mspgltk_api.h" #include "style.h" namespace Msp { namespace GLtk { -class Resources +/** +Stores resources such as styles and graphics. All widgets require a Resources +instance in constructor. +*/ +class MSPGLTK_API Resources: public DataFile::Collection { public: - - class Loader: public Msp::DataFile::Loader + class Loader: public Collection::Loader { - public: - Loader(Resources &); private: Resources &res; + public: + Loader(Resources &); + private: + void default_font(const std::string &); void font(const std::string &); - void texture(const std::string &); - void graphic(const std::string &); - void style(const std::string &, const std::string &); }; - Resources(); - ~Resources(); - const GL::Font &get_font(const std::string &) const; - const GL::Font &get_default_font() const; - const GL::Texture2D &get_texture(const std::string &) const; - const Graphic &get_graphic(const std::string &) const; - const Style &get_style(const std::string &, const std::string &) const; private: - struct StyleId - { - std::string widget; - std::string name; - - StyleId(const std::string &w, const std::string &n): widget(w), name(n) { } - bool operator<(const StyleId &) const; - }; + FS::Path path; + GL::Font *default_font = nullptr; + DataFile::DirectorySource *dir_src = nullptr; - typedef std::map FontMap; - typedef std::map TextureMap; - typedef std::map GraphicMap; - typedef std::map StyleMap; +public: + Resources(); + Resources(const FS::Path &); + ~Resources(); - FontMap fonts; - GL::Font *default_font; - TextureMap textures; - GraphicMap graphics; - StyleMap styles; + const GL::Font &get_default_font() const; + const GL::Sampler &get_default_sampler() const; - Resources(const Resources &); - Resources &operator=(const Resources &); +private: + GL::Module *create_module(const std::string &); + GL::Program *create_program(const std::string &); + GL::Sampler *create_sampler(const std::string &); + GL::Texture2D *create_texture(const std::string &); }; } // namespace GLtk