1 #ifndef MSP_GL_RESOURCES_H_
2 #define MSP_GL_RESOURCES_H_
4 #include <msp/datafile/collection.h>
14 class ResourceManager;
19 A collection class for GL resources.
21 The following types of objects can be loaded:
24 BasicMaterial (Material) .mat
26 DirectionalLight (Light) .light
32 Object (Renderable) .object
33 OccludedScene (Scene, Renderable) .scene
34 OrderedScene (Scene, Renderable) .scene
35 PbrMaterial (Material) .mat
36 PointLight (Light) .light
41 SimpleScene (Scene, Renderable) .scene
43 Texture1D (Texture) .tex
44 Texture2D (Texture) .tex .png .jpg
45 Texture3D (Texture) .tex
46 TextureCube (Texture) .tex
47 Texture2DArray (Texture) .tex
48 UnlitMaterial (Material) .mat
49 ZSortedScene (Scene, Renderable) .scene
51 This class is normally used by deriving from it and adding any necessary data
52 sources in the derived class.
54 A ResourceManager can be set to manage objects derived from Resource. Bulk
55 data for those objects will then be loaded in the background, without blocking
58 class Resources: virtual public DataFile::Collection
61 class Loader: public DataFile::DerivedObjectLoader<Resources, Collection::Loader>
67 template<typename T, typename L = typename T::GenericLoader>
68 void generic(const std::string &);
73 class GenericResourceLoader: public T::GenericLoader
79 GenericResourceLoader(Resources &r): T::GenericLoader(r), resources(r) { }
82 virtual void type(const DataFile::Symbol &);
85 ResourceManager *resource_manager;
87 static Resources *global_resources;
90 Resources(bool = true);
93 static Resources &get_global();
94 static const DataFile::CollectionSource &get_builtins();
96 void set_resource_manager(ResourceManager *);
99 template<typename T, typename L = typename T::GenericLoader>
100 T *create_generic(const std::string &);
102 Mesh *create_mesh(const std::string &);
103 Texture *create_texture(const std::string &);
104 Module *create_module(const std::string &);
105 Program *create_program(const std::string &);
108 static void set_debug_name(const std::string &, T &);