Texture2D *Resources::create_texture2d(const string &name)
{
string ext = FS::extpart(name);
- if(ext==".tex2d")
+ if(ext==".tex2d" && !resource_manager)
return 0;
if(RefPtr<IO::Seekable> io = open_raw(name))
RefPtr<Texture2D> tex = new Texture2D(resource_manager);
- Sampler &samp = tex->get_default_sampler();
- if(is_mipmapped(default_tex_filter))
+ if(ext==".tex2d")
{
- tex->set_auto_generate_mipmap(true);
- samp.set_mag_filter(LINEAR);
+ DataFile::Parser parser(*io, name);
+ Texture2D::Loader ldr(*tex, *this);
+ ldr.load(parser);
}
else
- samp.set_mag_filter(default_tex_filter);
- samp.set_min_filter(default_tex_filter);
- samp.set_max_anisotropy(default_tex_anisotropy);
+ {
+ Sampler &samp = tex->get_default_sampler();
+ if(is_mipmapped(default_tex_filter))
+ {
+ tex->set_auto_generate_mipmap(true);
+ samp.set_mag_filter(LINEAR);
+ }
+ else
+ samp.set_mag_filter(default_tex_filter);
+ samp.set_min_filter(default_tex_filter);
+ samp.set_max_anisotropy(default_tex_anisotropy);
+ }
if(resource_manager)
resource_manager->set_resource_location(*tex, *this, name);
void Texture::Loader::external_image(const string &fn)
{
- Graphics::Image img;
- load_external_image(img, fn);
- obj.image(img, get_levels(), srgb);
+ if(obj.manager)
+ obj.manager->set_resource_location(obj, get_collection(), fn);
+ else
+ {
+ Graphics::Image img;
+ load_external_image(img, fn);
+ obj.image(img, get_levels(), srgb);
+ }
}
void Texture::Loader::filter(TextureFilter f)