]> git.tdb.fi Git - libs/gl.git/blob - source/resources/resources.h
82d2f4c6798e4a9019380894b314aa56ad9aed57
[libs/gl.git] / source / resources / resources.h
1 #ifndef MSP_GL_RESOURCES_H_
2 #define MSP_GL_RESOURCES_H_
3
4 #include <msp/datafile/collection.h>
5 #include "texture.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Material;
11 class Mesh;
12 class Module;
13 class Program;
14 class ResourceManager;
15 class Scene;
16 class Texture2D;
17
18 /**
19 A collection class for GL resources.  Most useful as a base class for an
20 application-specific collection.
21 */
22 class Resources: virtual public DataFile::Collection
23 {
24 public:
25         class Loader: public DataFile::DerivedObjectLoader<Resources, Collection::Loader>
26         {
27         public:
28                 Loader(Resources &);
29
30         private:
31                 void scene(const std::string &);
32         };
33
34 private:
35         TextureFilter default_tex_filter;
36         float default_tex_anisotropy;
37         bool srgb_conversion;
38         ResourceManager *resource_manager;
39
40         static Resources *global_resources;
41
42 public:
43         Resources(bool = true);
44         virtual ~Resources();
45
46         static Resources &get_global();
47         static const DataFile::CollectionSource &get_builtins();
48
49         void set_default_texture_filter(TextureFilter);
50         void set_default_texture_anisotropy(float);
51
52         /** Enables or disables sRGB conversion.  If enabled, textures and material
53         colors are converted from sRGB to linear color space when loaded. */
54         DEPRECATED void set_srgb_conversion(bool);
55
56         DEPRECATED bool get_srgb_conversion() const { return srgb_conversion; }
57
58         void set_resource_manager(ResourceManager *);
59
60 protected:
61         Material *create_material(const std::string &);
62         Mesh *create_mesh(const std::string &);
63         Scene *create_scene(const std::string &);
64         Texture2D *create_texture2d(const std::string &);
65         Module *create_module(const std::string &);
66         Program *create_program(const std::string &);
67
68         template<typename T>
69         void set_debug_name(const std::string &, T &);
70 };
71
72 } // namespace GL
73 } // namespace Msp
74
75 #endif