#include <msp/core/except.h>
#include "ilwrap.h"
+using namespace std;
+
namespace Msp {
namespace GL {
Image::Image()
{
+ static bool init_done=false;
+
if(!init_done)
{
ilInit();
ilDeleteImages(1, &id);
}
-void Image::load(const std::string &fn)
+void Image::load_file(const string &fn)
{
ilBindImage(id);
if(!ilLoadImage(const_cast<char *>(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<void *>(data), size))
+ throw Exception("Error loading image from lump");
+}
+
PixelFormat Image::get_format() const
{
switch(ilGetInteger(IL_IMAGE_FORMAT))
return ilGetData();
}
-bool Image::init_done=false;
-
} // namespace GL
} // namespace Msp