]> git.tdb.fi Git - libs/gltk.git/blob - source/resources.h
ce85b972aec6ecae2003054dc7cd8fa5a29176c0
[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.  All widgets require a Resources
21 instance in constructor.
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         private:
34                 void default_font(const std::string &);
35                 void font(const std::string &);
36         };
37
38 private:
39         FS::Path path;
40         GL::Font *default_font;
41         DataFile::DirectorySource *dir_src;
42
43 public:
44         Resources();
45         Resources(const FS::Path &);
46 private:
47         void init();
48 public:
49         ~Resources();
50
51         const GL::Font &get_default_font() const;
52         const GL::Sampler &get_default_sampler() const;
53
54 private:
55         GL::Module *create_module(const std::string &);
56         GL::Program *create_program(const std::string &);
57         GL::Sampler *create_sampler(const std::string &);
58         GL::Texture2D *create_texture(const std::string &);
59 };
60
61 } // namespace GLtk
62 } // namespace Msp
63
64 #endif