if(resource_manager)
resource_manager->set_resource_location(*tex, *this, name);
else
- tex->image(image, srgb_conversion);
+ tex->image(image);
return tex.release();
}
/** Enables or disables sRGB conversion. If enabled, textures and material
colors are converted from sRGB to linear color space when loaded. */
- void set_srgb_conversion(bool);
+ DEPRECATED void set_srgb_conversion(bool);
- bool get_srgb_conversion() const { return srgb_conversion; }
+ DEPRECATED bool get_srgb_conversion() const { return srgb_conversion; }
void set_resource_manager(ResourceManager *);
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
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);
}
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);
+}
+
+void Texture::Loader::external_image_common(const string &fn)
{
if(obj.manager)
obj.manager->set_resource_location(obj, get_collection(), fn);
{
Graphics::Image img;
load_external_image(img, fn);
- obj.image(img, get_levels(), srgb);
+ obj.image(img, get_levels());
}
}
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)
{
protected:
unsigned levels;
- bool srgb;
public:
Loader(Texture &);
private:
void external_image(const std::string &);
+ void external_image_srgb(const std::string &);
+ void external_image_common(const std::string &);
void filter(TextureFilter);
void generate_mipmap(bool);
void image_data(const std::string &);
PixelFormat format;
PixelFormat storage_fmt;
FormatSwizzle swizzle;
+ bool use_srgb_format;
bool auto_gen_mipmap;
Sampler default_sampler;
DEPRECATED void set_compare_func(Predicate);
/// Loads a Graphics::Image from a file and uploads it to the texture.
- virtual void load_image(const std::string &, bool srgb = false);
+ virtual void load_image(const std::string &, unsigned = 0);
- virtual void load_image(const std::string &, unsigned, bool srgb = false);
+ DEPRECATED void load_image(const std::string &, bool srgb);
/** Uploads an image to the texture. If storage has not been defined, it
will be set to match the image. Otherwise the image must be compatible
- with the defined storage. Semantics depend on the type of texture.
+ with the defined storage. Semantics depend on the type of texture. */
+ virtual void image(const Graphics::Image &, unsigned = 0) = 0;
- If srgb is true and storage is determined by this call, then an sRGB pixel
- format will be used. */
- virtual void image(const Graphics::Image &, bool srgb = false);
-
- virtual void image(const Graphics::Image &, unsigned, bool srgb = false) = 0;
+ DEPRECATED void image(const Graphics::Image &, bool srgb);
GLenum get_target() const { return target; }
unsigned get_id() const { return id; }
sub_image(level, x, wd, data);
}
-void Texture1D::image(const Graphics::Image &img, unsigned lv, bool srgb)
+void Texture1D::image(const Graphics::Image &img, unsigned lv)
{
if(img.get_height()!=1)
throw incompatible_data("Texture1D::image");
unsigned w = img.get_width();
PixelFormat fmt = pixelformat_from_image(img);
if(width==0)
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), srgb), w, lv);
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, lv);
else if(w!=width)
throw incompatible_data("Texture1D::image");
DEPRECATED void image(unsigned, PixelComponents, DataType, const void *);
void sub_image(unsigned, int, unsigned, const void *);
DEPRECATED void sub_image(unsigned, int, unsigned, PixelComponents, DataType, const void *);
- virtual void image(const Graphics::Image &, unsigned, bool = false);
+ virtual void image(const Graphics::Image &, unsigned = 0);
using Texture::image;
unsigned get_width() const { return width; }
private:
Texture2D &texture;
IO::Seekable &io;
- bool srgb_conversion;
Buffer pixel_buffer;
char *mapped_address;
Graphics::Image image;
public:
AsyncLoader(Texture2D &, IO::Seekable &);
- void set_srgb_conversion(bool);
virtual bool needs_sync() const;
virtual bool process();
};
sub_image(level, x, y, wd, ht, data);
}
-void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb)
+void Texture2D::image(const Graphics::Image &img, unsigned lv)
{
- image(img, lv, srgb, false);
+ image(img, lv, false);
}
-void Texture2D::image(const Graphics::Image &img, unsigned lv, bool srgb, bool from_buffer)
+void Texture2D::image(const Graphics::Image &img, unsigned lv, bool from_buffer)
{
unsigned w = img.get_width();
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_image(img);
if(width==0)
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), srgb), w, h, lv);
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv);
else if(w!=width || h!=height || (lv && lv!=levels))
throw incompatible_data("Texture2D::image");
h = 1;
}
-Resource::AsyncLoader *Texture2D::load(IO::Seekable &io, const Resources *res)
+Resource::AsyncLoader *Texture2D::load(IO::Seekable &io, const Resources *)
{
AsyncLoader *ldr = new AsyncLoader(*this, io);
- if(res)
- ldr->set_srgb_conversion(res->get_srgb_conversion());
return ldr;
}
Texture2D::AsyncLoader::AsyncLoader(Texture2D &t, IO::Seekable &i):
texture(t),
io(i),
- srgb_conversion(false),
pixel_buffer(PIXEL_UNPACK_BUFFER),
mapped_address(0),
phase(0)
{ }
-void Texture2D::AsyncLoader::set_srgb_conversion(bool c)
-{
- srgb_conversion = c;
-}
-
bool Texture2D::AsyncLoader::needs_sync() const
{
return phase%2;
else
glGenTextures(1, &texture.id);
}
- texture.image(image, 0, srgb_conversion, true);
+ texture.image(image, 0, true);
}
++phase;
/** Updates the contents of the entire texture from an image. If storage
has not been defined, it will be set to match the image. Otherwise the
- image must match the defined storage.
-
- If srgb is true and storage is determined by this call, then an sRGB pixel
- format will be used. */
- virtual void image(const Graphics::Image &, unsigned lv, bool srgb = false);
+ image must match the defined storage. */
+ virtual void image(const Graphics::Image &, unsigned lv = 0);
using Texture::image;
private:
- void image(const Graphics::Image &, unsigned, bool, bool);
+ void image(const Graphics::Image &, unsigned, bool);
public:
unsigned get_width() const { return width; }
sub_image(level, x, y, z, wd, ht, dp, data);
}
-void Texture3D::image(const Graphics::Image &img, unsigned lv, bool srgb)
+void Texture3D::image(const Graphics::Image &img, unsigned lv)
{
unsigned w = img.get_width();
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_image(img);
if(width==0)
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), srgb), w, h, d, lv);
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, d, lv);
else if(w!=width || h!=height || d!=depth)
throw incompatible_data("Texture3D::load_image");
/** Updates the contents of the entire texture from an image. If storage
has not been defined, it will be set to match the image. In this case the
image will be treated as a stack of square layers and its height must be
- divisible by its width. Otherwise the image must match the defined storage.
-
- If srgb is true and storage is determined by this call, then an sRGB pixel
- format will be used. */
- virtual void image(const Graphics::Image &, unsigned, bool = false);
+ divisible by its width. Otherwise the image must match the defined
+ storage. */
+ virtual void image(const Graphics::Image &, unsigned = 0);
using Texture::image;
sub_image(face, level, x, y, wd, ht, data);
}
-void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool srgb)
+void TextureCube::image(TextureCubeFace face, const Graphics::Image &img)
{
unsigned w = img.get_width();
unsigned h = img.get_height();
if(w!=h)
throw incompatible_data("TextureCube::image");
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), srgb), w);
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w);
}
else if(w!=size || h!=size)
throw incompatible_data("TextureCube::image");
image(face, 0, img.get_data());
}
-void TextureCube::image(const Graphics::Image &img, unsigned lv, bool srgb)
+void TextureCube::image(TextureCubeFace face, const Graphics::Image &img, bool)
+{
+ image(face, img);
+}
+
+void TextureCube::image(const Graphics::Image &img, unsigned lv)
{
unsigned w = img.get_width();
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_image(img);
if(size==0)
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), srgb), w, lv);
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, lv);
else if(w!=size || h!=size)
throw incompatible_data("TextureCube::image");
RefPtr<IO::Seekable> io = get_collection().open_raw(fn);
img.load_io(*io);
- obj.image(face, img, srgb);
+ obj.image(face, img);
}
void TextureCube::Loader::image_data(TextureCubeFace face, const string &data)
IO::Memory mem(data.data(), data.size());
img.load_io(mem);
- obj.image(face, img, srgb);
+ obj.image(face, img);
}
void TextureCube::Loader::raw_data(TextureCubeFace face, const string &data)
int x, int y, unsigned w, unsigned h,
PixelComponents comp, DataType type, const void *data);
- void image(TextureCubeFace, const Graphics::Image &, bool = false);
+ void image(TextureCubeFace, const Graphics::Image &);
- virtual void image(const Graphics::Image &, unsigned, bool = false);
+ DEPRECATED void image(TextureCubeFace, const Graphics::Image &, bool);
+
+ virtual void image(const Graphics::Image &, unsigned = 0);
using Texture::image;
unsigned get_size() const { return size; }