default_sampler.set_compare(f);
}
-void Texture::load_image(const string &fn, bool srgb)
+void Texture::load_image(const string &fn, bool)
{
- load_image(fn, 0, srgb);
+ load_image(fn, 0U);
}
-void Texture::load_image(const string &fn, unsigned lv, bool srgb)
+void Texture::load_image(const string &fn, unsigned lv)
{
Graphics::Image img;
img.load_file(fn);
- image(img, lv, srgb);
+ image(img, lv);
}
-void Texture::image(const Graphics::Image &img, bool srgb)
+void Texture::image(const Graphics::Image &img, bool)
{
- image(img, 0, srgb);
+ image(img, 0U);
}
void Texture::bind_to(unsigned i) const
glBindTexture(target, id);
}
- default_sampler.bind_to(i);
+ if(!unit.get_sampler())
+ default_sampler.bind_to(i);
}
}
unit.bind();
glBindTexture(cur->target, 0);
}
+
+ if(unit.get_sampler()==&cur->default_sampler)
+ Sampler::unbind_from(i);
}
}
void Texture::Loader::init()
{
levels = 0;
- if(Resources *res = dynamic_cast<Resources *>(coll))
- srgb = res->get_srgb_conversion();
- else
- srgb = false;
add("external_image", &Loader::external_image);
+ add("external_image_srgb", &Loader::external_image);
add("filter", &Loader::filter);
add("generate_mipmap", &Loader::generate_mipmap);
add("image_data", &Loader::image_data);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-void Texture::Loader::external_image(const string &fn)
+void Texture::Loader::load_external_image(Graphics::Image &img, const std::string &fn)
{
- Graphics::Image img;
RefPtr<IO::Seekable> io = get_collection().open_raw(fn);
if(!io)
throw IO::file_not_found(fn);
img.load_io(*io);
+}
+
+void Texture::Loader::external_image(const string &fn)
+{
+ obj.use_srgb_format = false;
+ external_image_common(fn);
+}
+
+void Texture::Loader::external_image_srgb(const string &fn)
+{
+ obj.use_srgb_format = true;
+ external_image_common(fn);
+}
- obj.image(img, get_levels(), srgb);
+void Texture::Loader::external_image_common(const string &fn)
+{
+ 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());
+ }
}
void Texture::Loader::filter(TextureFilter f)
IO::Memory mem(data.data(), data.size());
img.load_io(mem);
- obj.image(img, get_levels(), srgb);
+ obj.image(img, get_levels());
}
void Texture::Loader::mag_filter(TextureFilter f)