X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=94224147c70434b53bcb8ef9ea78328e9f81284b;hp=8c8ad3784e4a0a32faad55b49a25dca54fd9c2fb;hb=HEAD;hpb=edd2a01b3c696df8630ac6a97e9b55a95fe7e112 diff --git a/source/texture2d.cpp b/source/texture2d.cpp deleted file mode 100644 index 8c8ad378..00000000 --- a/source/texture2d.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "bindable.h" -#include "error.h" -#include "texture2d.h" - -using namespace std; - -namespace Msp { -namespace GL { - -Texture2D::Texture2D(): - Texture(GL_TEXTURE_2D), - width(0), - height(0), - allocated(0) -{ } - -void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht) -{ - if(width>0) - throw invalid_operation("Texture2D::storage"); - if(wd==0 || ht==0) - throw invalid_argument("Texture2D::storage"); - - ifmt = fmt; - width = wd; - height = ht; -} - -void Texture2D::allocate(unsigned level) -{ - if(allocated&(1<>=1, h>>=1, ++level) ; - allocated |= (1<>= level; - h >>= level; - - if(!w && h) - w = 1; - else if(!h && w) - h = 1; -} - - -Texture2D::Loader::Loader(Texture2D &t): - DataFile::DerivedObjectLoader(t) -{ - add("image_data", &Loader::image_data); - add("raw_data", &Loader::raw_data); - add("storage", &Loader::storage); - add("storage", &Loader::storage_b); -} - -void Texture2D::Loader::image_data(const string &data) -{ - Graphics::Image img; - img.load_memory(data.data(), data.size()); - - obj.image(img); -} - -void Texture2D::Loader::raw_data(const string &data) -{ - obj.image(0, obj.ifmt, UNSIGNED_BYTE, data.data()); -} - -void Texture2D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h) -{ - obj.storage(fmt, w, h); -} - -void Texture2D::Loader::storage_b(PixelFormat fmt, unsigned w, unsigned h, unsigned) -{ - storage(fmt, w, h); -} - -} // namespace GL -} // namespace Msp