X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=baee22eefc56b31f9fe41c44c53a888598c3cbba;hb=e92458a4a0e6191bff549a8b316dbbbd7c56e90f;hp=fbf86a43b77fe79dc2f81120a98b516aeea05b85;hpb=a80b074c70ec991f27114efd13686038cf42c493;p=libs%2Fgl.git diff --git a/source/texture2d.cpp b/source/texture2d.cpp index fbf86a43..baee22ee 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -35,7 +35,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 +45,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"); @@ -73,7 +73,7 @@ void Texture2D::image(const Image &img) 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()); } @@ -81,6 +81,8 @@ 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) @@ -91,5 +93,16 @@ void Texture2D::Loader::image_data(const string &data) static_cast(tex).image(img); } +void Texture2D::Loader::raw_data(const string &data) +{ + Texture2D &t2d=static_cast(tex);; + 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); +} + } // namespace GL } // namespace Msp