X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=fbf86a43b77fe79dc2f81120a98b516aeea05b85;hp=455c7314cb4d2a04676b1ac6e6612884e95ef212;hb=a80b074c70ec991f27114efd13686038cf42c493;hpb=530ace590ddb8024fbffc944d006aae7876a25f9 diff --git a/source/texture2d.cpp b/source/texture2d.cpp index 455c7314..fbf86a43 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -11,8 +11,6 @@ Distributed under the LGPL using namespace std; -#include - namespace Msp { namespace GL { @@ -60,8 +58,13 @@ void Texture2D::sub_image(int level, int x, int y, sizei wd, sizei ht, PixelForm void Texture2D::load_image(const string &fn) { Image img; - img.load(fn); + img.load_file(fn); + + image(img); +} +void Texture2D::image(const Image &img) +{ unsigned w=img.get_width(); unsigned h=img.get_height(); PixelFormat fmt=img.get_format(); @@ -73,5 +76,20 @@ void Texture2D::load_image(const string &fn) image(0, fmt, GL_UNSIGNED_BYTE, img.get_data()); } + +Texture2D::Loader::Loader(Texture2D &t): + Texture::Loader(t) +{ + add("image_data", &Loader::image_data); +} + +void Texture2D::Loader::image_data(const string &data) +{ + Image img; + img.load_lump(data.data(), data.size()); + + static_cast(tex).image(img); +} + } // namespace GL } // namespace Msp