Do not define GL_GLEXT_PROTOTYPES in blend.cpp since glBlendEquation is to be used through the extension mechanism
Update svn:ignore
require "mspdatafile";
require "opengl";
- feature "devil" "Include DevIL support for loading image files";
- if "with_devil"
- {
- require "devil";
- build_info
- {
- library "ILU";
- };
- };
-
library "mspgl"
{
source "source";
Distributed under the LGPL
*/
-#define GL_GLEXT_PROTOTYPES
#include "blend.h"
#include "extension.h"
#include "version_1_2.h"
+++ /dev/null
-/* $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
+++ /dev/null
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#ifndef MSP_GL_ILWRAP_H_
-#define MSP_GL_ILWRAP_H_
-
-#include "pixelformat.h"
-
-namespace Msp {
-namespace GL {
-
-class Image
-{
-private:
- unsigned id;
-
-public:
- Image();
- ~Image();
-
- void load_file(const std::string &);
- void load_lump(const void *, unsigned);
- PixelFormat get_format() const;
- unsigned get_width() const;
- unsigned get_height() const;
- const void *get_data() const;
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
Distributed under the LGPL
*/
+#include "except.h"
#include "pixelformat.h"
using namespace std;
return in;
}
+PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf)
+{
+ switch(pf)
+ {
+ case Graphics::COLOR_INDEX: return COLOR_INDEX;
+ case Graphics::LUMINANCE: return LUMINANCE;
+ case Graphics::LUMINANCE_ALPHA: return LUMINANCE_ALPHA;
+ case Graphics::RGB: return RGB;
+ case Graphics::RGBA: return RGBA;
+ case Graphics::BGR: return BGR;
+ case Graphics::BGRA: return BGRA;
+ default: throw InvalidParameterValue("Unknown Graphics::PixelFormat");
+ }
+}
+
} // namespace GL
} // namespace Msp
#define MSP_GL_PIXELFORMAT_H_
#include <istream>
+#include <msp/gbase/pixelformat.h>
#include "gl.h"
namespace Msp {
std::istream &operator>>(std::istream &, PixelFormat &);
+PixelFormat pixelformat_from_graphics(Graphics::PixelFormat);
+
} // namespace GL
} // namespace Msp
*/
#include "except.h"
-#include "ilwrap.h"
#include "texture2d.h"
using namespace std;
void Texture2D::load_image(const string &fn)
{
- Image img;
+ Graphics::Image img;
img.load_file(fn);
image(img);
}
-void Texture2D::image(const Image &img)
+void Texture2D::image(const Graphics::Image &img)
{
unsigned w=img.get_width();
unsigned h=img.get_height();
- PixelFormat fmt=img.get_format();
+ PixelFormat fmt=pixelformat_from_graphics(img.get_format());
if(width==0)
storage(fmt, w, h, 0);
else if(w!=width || h!=height)
void Texture2D::Loader::image_data(const string &data)
{
- Image img;
- img.load_lump(data.data(), data.size());
+ Graphics::Image img;
+ img.load_memory(data.data(), data.size());
static_cast<Texture2D &>(tex).image(img);
}
#include <string>
#include <msp/datafile/loader.h>
+#include <msp/gbase/image.h>
#include "pixelformat.h"
#include "texture.h"
namespace Msp {
namespace GL {
-class Image;
-
/**
Two-dimensional texture class. This is the most common type of texture.
*/
sizei get_height() const { return height; }
private:
- void image(const Image &);
+ void image(const Graphics::Image &);
};
} // namespace GL
*/
#include <cmath>
+#include <msp/gbase/image.h>
#include "except.h"
#include "extension.h"
-#include "ilwrap.h"
#include "texture3d.h"
#include "version_1_2.h"
void Texture3D::load_image(const string &fn, int dp)
{
- Image img;
+ Graphics::Image img;
img.load_file(fn);
unsigned w=img.get_width();
else if(dp>0)
d=dp;
- PixelFormat fmt=img.get_format();
+ PixelFormat fmt=pixelformat_from_graphics(img.get_format());
if(width==0)
storage(fmt, w, h, d, 0);
else if(w!=width || h!=height || d!=depth)