]> 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 293670f9cc06f78563c07a73d5cee3964bf5d781..f1aec26b283b2d6cb871f551e84456ffcc8e6b1e 100644 (file)
@@ -28,10 +28,24 @@ public:
                Loader(Resources &);
 
        private:
-               void scene(const std::string &);
+               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;
 
@@ -53,16 +67,16 @@ 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 &);
 
        template<typename T>
-       void set_debug_name(const std::string &, T &);
+       static void set_debug_name(const std::string &, T &);
 };
 
 } // namespace GL