]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2d.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / texture2d.cpp
diff --git a/source/texture2d.cpp b/source/texture2d.cpp
deleted file mode 100644 (file)
index 8935933..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
-#include "bindable.h"
-#include "except.h"
-#include "texture2d.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Texture2D::Texture2D():
-       Texture(GL_TEXTURE_2D),
-       width(0),
-       height(0)
-{ }
-
-void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, int brd)
-{
-       if(width>0)
-               throw InvalidState("Texture storage may only be specified once");
-       if(wd==0 || ht==0)
-               throw InvalidParameterValue("Invalid texture dimensions");
-
-       ifmt = fmt;
-       width = wd;
-       height = ht;
-       border = brd;
-}
-
-void Texture2D::image(int level, PixelFormat fmt, DataType type, const void *data)
-{
-       if(width==0)
-               throw InvalidState("Texture storage has not been specified");
-
-       Bind _bind(this, true);
-       glTexImage2D(target, level, ifmt, width, height, border, fmt, type, data);
-}
-
-void Texture2D::sub_image(int level, int x, int y, unsigned wd, unsigned ht, PixelFormat fmt, DataType type, const void *data)
-{
-       if(width==0)
-               throw InvalidState("Texture storage has not been specified");
-
-       Bind _bind(this, true);
-       glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
-}
-
-void Texture2D::load_image(const string &fn)
-{
-       Graphics::Image img;
-       img.load_file(fn);
-
-       image(img);
-}
-
-void Texture2D::image(const Graphics::Image &img)
-{
-       unsigned w = img.get_width();
-       unsigned h = img.get_height();
-       PixelFormat fmt = pixelformat_from_graphics(img.get_format());
-       if(width==0)
-               storage(fmt, w, h, 0);
-       else if(w!=width || h!=height)
-               throw IncompatibleData("Image does not match texture storage");
-
-       image(0, fmt, UNSIGNED_BYTE, img.get_data());
-}
-
-
-Texture2D::Loader::Loader(Texture2D &t):
-       Texture::Loader(t)
-{
-       add("image_data", &Loader::image_data);
-       add("raw_data", &Loader::raw_data);
-       add("storage", &Loader::storage);
-}
-
-void Texture2D::Loader::image_data(const string &data)
-{
-       Graphics::Image img;
-       img.load_memory(data.data(), data.size());
-
-       static_cast<Texture2D &>(obj).image(img);
-}
-
-void Texture2D::Loader::raw_data(const string &data)
-{
-       Texture2D &t2d = static_cast<Texture2D &>(obj);
-       t2d.image(0, t2d.ifmt, UNSIGNED_BYTE, data.data());
-}
-
-void Texture2D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h, unsigned b)
-{
-       static_cast<Texture2D &>(obj).storage(fmt, w, h, b);
-}
-
-} // namespace GL
-} // namespace Msp