X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.h;h=ce85b972aec6ecae2003054dc7cd8fa5a29176c0;hb=56c41b294aa47a38ac3e1be70d4868f260cb4274;hp=001fa632b2a2a275776199d5795fa7451cf2d4b6;hpb=c1f038acb91eb3bfaa34dfd4729d19ed3f871a42;p=libs%2Fgltk.git diff --git a/source/resources.h b/source/resources.h index 001fa63..ce85b97 100644 --- a/source/resources.h +++ b/source/resources.h @@ -2,61 +2,60 @@ #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::Parser::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; + DataFile::DirectorySource *dir_src; - typedef std::map FontMap; - typedef std::map TextureMap; - typedef std::map GraphicMap; - typedef std::map StyleMap; +public: + Resources(); + Resources(const FS::Path &); +private: + void init(); +public: + ~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