]> git.tdb.fi Git - libs/gl.git/blobdiff - source/ilwrap.cpp
Move Image to mspgbase
[libs/gl.git] / source / ilwrap.cpp
diff --git a/source/ilwrap.cpp b/source/ilwrap.cpp
deleted file mode 100644 (file)
index b9fb499..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#ifdef WITH_DEVIL
-#include <IL/il.h>
-#endif
-#include <msp/core/except.h>
-#include "ilwrap.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Image::Image()
-{
-#ifdef WITH_DEVIL
-       static bool init_done=false;
-
-       if(!init_done)
-       {
-               ilInit();
-               ilEnable(IL_ORIGIN_SET);
-               ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
-               init_done=true;
-       }
-
-       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<char *>(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<void *>(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;
-       case IL_LUMINANCE: return LUMINANCE;
-       case IL_LUMINANCE_ALPHA: return LUMINANCE_ALPHA;
-       case IL_RGB: return RGB;
-       case IL_RGBA: return RGBA;
-       case IL_BGR: return BGR;
-       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
-} // namespace Msp