]> git.tdb.fi Git - libs/gltk.git/blob - source/resources.h
Style and comment updates
[libs/gltk.git] / source / resources.h
1 #ifndef MSP_GLTK_RESOURCES_H_
2 #define MSP_GLTK_RESOURCES_H_
3
4 #include <msp/gl/font.h>
5 #include <msp/gl/module.h>
6 #include <msp/gl/program.h>
7 #include <msp/gl/sampler.h>
8 #include <msp/gl/texture.h>
9 #include <msp/datafile/collection.h>
10 #include <msp/datafile/directorysource.h>
11 #include <msp/fs/path.h>
12 #include "graphic.h"
13 #include "mspgltk_api.h"
14 #include "style.h"
15
16 namespace Msp {
17 namespace GLtk {
18
19 /**
20 Stores resources such as styles and graphics.  The Root widget requires a
21 Resources instance as constructor parameter.
22 */
23 class MSPGLTK_API Resources: public DataFile::Collection
24 {
25 public:
26         class Loader: public Collection::Loader
27         {
28         private:
29                 Resources &res;
30
31         public:
32                 Loader(Resources &);
33
34         private:
35                 void default_font(const std::string &);
36                 void font(const std::string &);
37         };
38
39 private:
40         FS::Path path;
41         GL::Font *default_font = nullptr;
42         DataFile::DirectorySource *dir_src = nullptr;
43
44 public:
45         Resources();
46         Resources(const FS::Path &);
47         ~Resources();
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