void RenderMethod::Loader::material_inline()
{
- Material::GenericLoader ldr(coll);
+ Material::GenericLoader ldr(get_collection());
load_sub_with(ldr);
- RefPtr<Material> mat = ldr.get_material();
+ RefPtr<Material> mat = ldr.get_object();
get_collection().add(inline_base_name+".mat", mat.get());
obj.material = mat.release();
obj.set_material_textures();
add_type<Lighting>().suffix(".lightn").keyword("lighting")
.notify(&Resources::set_debug_name<Lighting>);
add_type<Material>().suffix(".mat")
- .creator(&Resources::create_material).notify(&Resources::set_debug_name<Material>);
+ .creator(&Resources::create_generic<Material>).notify(&Resources::set_debug_name<Material>);
add_type<Mesh>().keyword("mesh")
.creator(&Resources::create_mesh).notify(&Resources::set_debug_name<Mesh>);
add_type<Module>().suffix(".glsl").suffix(".spv")
add_type<Sampler>().suffix(".samp").keyword("sampler")
.notify(&Resources::set_debug_name<Sampler>);
add_type<Scene>().suffix(".scene")
- .creator(&Resources::create_scene);
+ .creator(&Resources::create_generic<Scene>);
add_type<Technique>().suffix(".tech").keyword("technique")
.notify(&Resources::set_debug_name<Technique>);
add_type<Texture1D>().base<Texture>().suffix(".tex1d").keyword("texture1d")
resource_manager = m;
}
-Material *Resources::create_material(const string &name)
+template<typename T>
+T *Resources::create_generic(const string &name)
{
if(RefPtr<IO::Seekable> io = open_raw(name))
{
DataFile::Parser parser(*io, name);
- Material::GenericLoader ldr(this);
+ typename T::GenericLoader ldr(*this);
ldr.load(parser);
- return ldr.get_material();
+ return ldr.get_object();
}
return 0;
return 0;
}
-Scene *Resources::create_scene(const string &name)
-{
- if(RefPtr<IO::Seekable> io = open_raw(name))
- {
- DataFile::Parser parser(*io, name);
- Scene::GenericLoader ldr(*this);
- ldr.load(parser);
- return ldr.get_scene();
- }
-
- return 0;
-}
-
Texture2D *Resources::create_texture2d(const string &name)
{
string ext = FS::extpart(name);
{
Scene::GenericLoader ldr(obj);
load_sub_with(ldr);
- obj.add(name, ldr.get_scene());
+ obj.add(name, ldr.get_object());
}
} // namespace GL
void set_resource_manager(ResourceManager *);
protected:
- Material *create_material(const std::string &);
+ template<typename T>
+ T *create_generic(const std::string &);
+
Mesh *create_mesh(const std::string &);
- Scene *create_scene(const std::string &);
Texture2D *create_texture2d(const std::string &);
Module *create_module(const std::string &);
Program *create_program(const std::string &);