X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Filwrap.cpp;h=a1ae1631776539ec5d2be163af3e8f86ced48549;hb=a80b074c70ec991f27114efd13686038cf42c493;hp=be8442bee741a325199a4f45865a86bbbcea549c;hpb=a361efc05fcad11b2918f3cd7abdebe794b131d8;p=libs%2Fgl.git diff --git a/source/ilwrap.cpp b/source/ilwrap.cpp index be8442be..a1ae1631 100644 --- a/source/ilwrap.cpp +++ b/source/ilwrap.cpp @@ -9,11 +9,15 @@ Distributed under the LGPL #include #include "ilwrap.h" +using namespace std; + namespace Msp { namespace GL { Image::Image() { + static bool init_done=false; + if(!init_done) { ilInit(); @@ -30,13 +34,20 @@ Image::~Image() ilDeleteImages(1, &id); } -void Image::load(const std::string &fn) +void Image::load_file(const string &fn) { ilBindImage(id); if(!ilLoadImage(const_cast(fn.c_str()))) throw Exception("Error loading image "+fn); } +void Image::load_lump(const void *data, unsigned size) +{ + ilBindImage(id); + if(!ilLoadL(IL_TYPE_UNKNOWN, const_cast(data), size)) + throw Exception("Error loading image from lump"); +} + PixelFormat Image::get_format() const { switch(ilGetInteger(IL_IMAGE_FORMAT)) @@ -67,7 +78,5 @@ const void *Image::get_data() const return ilGetData(); } -bool Image::init_done=false; - } // namespace GL } // namespace Msp