X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Filwrap.cpp;h=b9fb4998adb39687efe7e4217439718077244ee4;hb=d23880571efc16dff1cfeeb92f35fe54c8f64c3d;hp=a1ae1631776539ec5d2be163af3e8f86ced48549;hpb=a80b074c70ec991f27114efd13686038cf42c493;p=libs%2Fgl.git diff --git a/source/ilwrap.cpp b/source/ilwrap.cpp index a1ae1631..b9fb4998 100644 --- a/source/ilwrap.cpp +++ b/source/ilwrap.cpp @@ -5,7 +5,9 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#ifdef WITH_DEVIL #include +#endif #include #include "ilwrap.h" @@ -16,6 +18,7 @@ namespace GL { Image::Image() { +#ifdef WITH_DEVIL static bool init_done=false; if(!init_done) @@ -27,29 +30,43 @@ Image::Image() } ilGenImages(1, &id); +#else + throw Exception("DevIL support not compiled in"); +#endif } Image::~Image() { +#ifdef WITH_DEVIL ilDeleteImages(1, &id); +#endif } void Image::load_file(const string &fn) { +#ifdef WITH_DEVIL ilBindImage(id); if(!ilLoadImage(const_cast(fn.c_str()))) throw Exception("Error loading image "+fn); +#else + (void)fn; +#endif } void Image::load_lump(const void *data, unsigned size) { +#ifdef WITH_DEVIL ilBindImage(id); if(!ilLoadL(IL_TYPE_UNKNOWN, const_cast(data), size)) throw Exception("Error loading image from lump"); +#else + (void)data; (void)size; +#endif } PixelFormat Image::get_format() const { +#ifdef WITH_DEVIL switch(ilGetInteger(IL_IMAGE_FORMAT)) { case IL_COLOR_INDEX: return COLOR_INDEX; @@ -61,21 +78,36 @@ PixelFormat Image::get_format() const case IL_BGRA: return BGRA; default: throw InvalidParameterValue("Unknown pixel format in image"); } +#else + return RGB; +#endif } unsigned Image::get_width() const { +#ifdef WITH_DEVIL return ilGetInteger(IL_IMAGE_WIDTH); +#else + return 0; +#endif } unsigned Image::get_height() const { +#ifdef WITH_DEVIL return ilGetInteger(IL_IMAGE_HEIGHT); +#else + return 0; +#endif } const void *Image::get_data() const { +#ifdef WITH_DEVIL return ilGetData(); +#else + return 0; +#endif } } // namespace GL