add("wrap_t", &Loader::wrap_t);
}
+unsigned Texture::Loader::get_levels() const
+{
+ return (is_mipmapped(obj.default_sampler.get_min_filter()) ? levels : 1);
+}
+
void Texture::Loader::external_image(const string &fn)
{
Graphics::Image img;
throw IO::file_not_found(fn);
img.load_io(*io);
- obj.image(img, levels, srgb);
+ obj.image(img, get_levels(), srgb);
}
void Texture::Loader::filter(TextureFilter f)
IO::Memory mem(data.data(), data.size());
img.load_io(mem);
- obj.image(img, levels, srgb);
+ obj.image(img, get_levels(), srgb);
}
void Texture::Loader::mag_filter(TextureFilter f)
private:
void init();
+ unsigned get_levels() const;
+
void external_image(const std::string &);
void filter(TextureFilter);
void generate_mipmap(bool);
unsigned w = img.get_width();
PixelFormat fmt = pixelformat_from_graphics(img.get_format());
if(width==0)
- {
- unsigned l = (is_mipmapped(min_filter) ? lv : 1);
- storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, l);
- }
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, lv);
else if(w!=width)
throw incompatible_data("Texture1D::image");
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_graphics(img.get_format());
if(width==0)
- {
- unsigned l = (is_mipmapped(min_filter) ? lv : 1);
- storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, l);
- }
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, lv);
else if(w!=width || h!=height || (lv && lv!=levels))
throw incompatible_data("Texture2D::image");
PixelFormat fmt = pixelformat_from_graphics(img.get_format());
if(width==0)
- {
- unsigned l = (is_mipmapped(min_filter) ? lv : 1);
- storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, d, l);
- }
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, d, lv);
else if(w!=width || h!=height || d!=depth)
throw incompatible_data("Texture3D::load_image");
PixelFormat fmt = pixelformat_from_graphics(img.get_format());
if(size==0)
- {
- unsigned l = (is_mipmapped(min_filter) ? lv : 1);
- storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, l);
- }
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, lv);
else if(w!=size || h!=size)
throw incompatible_data("TextureCube::image");