]> git.tdb.fi Git - libs/gltk.git/blob - source/resources.h
7569119a35109d6d46c6b94501b70bc7eabd9472
[libs/gltk.git] / source / resources.h
1 #ifndef MSP_GLTK_RESOURCES_H_
2 #define MSP_GLTK_RESOURCES_H_
3
4 #include <memory>
5 #include <msp/gl/font.h>
6 #include <msp/gl/module.h>
7 #include <msp/gl/program.h>
8 #include <msp/gl/sampler.h>
9 #include <msp/gl/texture.h>
10 #include <msp/datafile/collection.h>
11 #include <msp/datafile/directorysource.h>
12 #include <msp/fs/path.h>
13 #include "graphic.h"
14 #include "mspgltk_api.h"
15 #include "style.h"
16
17 namespace Msp {
18 namespace GLtk {
19
20 /**
21 Stores resources such as styles and graphics.  The Root widget requires a
22 Resources instance as constructor parameter.
23 */
24 class MSPGLTK_API Resources: public DataFile::Collection
25 {
26 public:
27         class Loader: public Collection::Loader
28         {
29         private:
30                 Resources &res;
31
32         public:
33                 Loader(Resources &);
34
35         private:
36                 void default_font(const std::string &);
37                 void font(const std::string &);
38         };
39
40 private:
41         FS::Path path;
42         GL::Font *default_font = nullptr;
43         std::unique_ptr<DataFile::DirectorySource> dir_src;
44
45 public:
46         Resources();
47         Resources(const FS::Path &);
48
49         const GL::Font &get_default_font() const;
50         const GL::Sampler &get_default_sampler() const;
51
52 private:
53         GL::Module *create_module(const std::string &);
54         GL::Program *create_program(const std::string &);
55         GL::Sampler *create_sampler(const std::string &);
56         GL::Texture2D *create_texture(const std::string &);
57 };
58
59 } // namespace GLtk
60 } // namespace Msp
61
62 #endif