X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture.cpp;h=004d78c2abc38d1b9bc383b361cefae647b8ac06;hb=ccbfdfa0d9d796244b1ecc0fa3faa2c50304811b;hp=8d43143c9d734c218211d070890bf4cd080b42ed;hpb=f35535633aab06e80f0666d8551431364654c6dc;p=libs%2Fgl.git diff --git a/source/texture.cpp b/source/texture.cpp index 8d43143c..004d78c2 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "error.h" #include "resourcemanager.h" @@ -203,6 +204,14 @@ void Texture::set_compare_func(Predicate f) update_parameter(COMPARE_FUNC); } +void Texture::load_image(const string &fn, bool srgb) +{ + Graphics::Image img; + img.load_file(fn); + + image(img, srgb); +} + void Texture::bind_to(unsigned i) const { if(!id) @@ -279,10 +288,12 @@ void Texture::Loader::init() else srgb = false; + add("external_image", &Loader::external_image); add("filter", &Loader::filter); - add("max_anisotropy", &Loader::max_anisotropy); add("generate_mipmap", &Loader::generate_mipmap); + add("image_data", &Loader::image_data); add("mag_filter", &Loader::mag_filter); + add("max_anisotropy", &Loader::max_anisotropy); add("min_filter", &Loader::min_filter); add("wrap", &Loader::wrap); add("wrap_r", &Loader::wrap_r); @@ -290,6 +301,15 @@ void Texture::Loader::init() add("wrap_t", &Loader::wrap_t); } +void Texture::Loader::external_image(const string &fn) +{ + Graphics::Image img; + RefPtr io = get_collection().open_raw(fn); + img.load_io(*io); + + obj.image(img, srgb); +} + void Texture::Loader::filter(TextureFilter f) { obj.set_filter(f); @@ -300,6 +320,15 @@ void Texture::Loader::generate_mipmap(bool gm) obj.set_generate_mipmap(gm); } +void Texture::Loader::image_data(const string &data) +{ + Graphics::Image img; + IO::Memory mem(data.data(), data.size()); + img.load_io(mem); + + obj.image(img, srgb); +} + void Texture::Loader::mag_filter(TextureFilter f) { obj.set_mag_filter(f);