X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=c1f6e0e9e7bd75f664cc682209b551746d3f4e48;hb=927a1aa0a3a27e463ec0efc08bd08e7c4e969909;hp=8a93d031b6fd36a781ab5916e7019ba6036b0388;hpb=d1800d7ea80290f4913d0203241cef1409656522;p=libs%2Fgl.git diff --git a/source/texture2d.cpp b/source/texture2d.cpp index 8a93d031..c1f6e0e9 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -6,7 +6,6 @@ Distributed under the LGPL */ #include "except.h" -#include "ilwrap.h" #include "texture2d.h" using namespace std; @@ -35,7 +34,7 @@ void Texture2D::storage(PixelFormat fmt, sizei wd, sizei ht, int brd) border=brd; } -void Texture2D::image(int level, PixelFormat fmt, GLenum type, const void *data) +void Texture2D::image(int level, PixelFormat fmt, DataType type, const void *data) { if(width==0) throw InvalidState("Texture storage has not been specified"); @@ -45,7 +44,7 @@ void Texture2D::image(int level, PixelFormat fmt, GLenum type, const void *data) glTexImage2D(target, level, ifmt, width, height, border, fmt, type, data); } -void Texture2D::sub_image(int level, int x, int y, sizei wd, sizei ht, PixelFormat fmt, GLenum type, const void *data) +void Texture2D::sub_image(int level, int x, int y, sizei wd, sizei ht, PixelFormat fmt, DataType type, const void *data) { if(width==0) throw InvalidState("Texture storage has not been specified"); @@ -57,23 +56,23 @@ void Texture2D::sub_image(int level, int x, int y, sizei wd, sizei ht, PixelForm 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) throw IncompatibleData("Image does not match texture storage"); - image(0, fmt, GL_UNSIGNED_BYTE, img.get_data()); + image(0, fmt, UNSIGNED_BYTE, img.get_data()); } @@ -87,21 +86,21 @@ Texture2D::Loader::Loader(Texture2D &t): 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(tex).image(img); + static_cast(obj).image(img); } void Texture2D::Loader::raw_data(const string &data) { - Texture2D &t2d=static_cast(tex);; - t2d.image(0, t2d.ifmt, GL_UNSIGNED_BYTE, data.data()); + Texture2D &t2d=static_cast(obj); + t2d.image(0, t2d.ifmt, UNSIGNED_BYTE, data.data()); } void Texture2D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h, unsigned b) { - static_cast(tex).storage(fmt, w, h, b); + static_cast(obj).storage(fmt, w, h, b); } } // namespace GL