]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resources/resources.h
Load textures in a type-generic way
[libs/gl.git] / source / resources / resources.h
index f830faaa510ff722a7dfc485195b015217efef48..f1aec26b283b2d6cb871f551e84456ffcc8e6b1e 100644 (file)
@@ -28,11 +28,24 @@ public:
                Loader(Resources &);
 
        private:
-               template<typename T>
+               template<typename T, typename L = typename T::GenericLoader>
                void generic(const std::string &);
        };
 
 private:
+       template<typename T>
+       class GenericResourceLoader: public T::GenericLoader
+       {
+       private:
+               Resources &resources;
+
+       public:
+               GenericResourceLoader(Resources &r): T::GenericLoader(r), resources(r) { }
+
+       protected:
+               virtual void type(const DataFile::Symbol &);
+       };
+
        bool srgb_conversion;
        ResourceManager *resource_manager;
 
@@ -54,11 +67,11 @@ public:
        void set_resource_manager(ResourceManager *);
 
 protected:
-       template<typename T>
+       template<typename T, typename L = typename T::GenericLoader>
        T *create_generic(const std::string &);
 
        Mesh *create_mesh(const std::string &);
-       Texture2D *create_texture2d(const std::string &);
+       Texture *create_texture(const std::string &);
        Module *create_module(const std::string &);
        Program *create_program(const std::string &);