X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture1d.cpp;h=0dc85586cbc2e76c328077ca9b666b96c16873e9;hb=e01371d38e290b4c526146fd5d1388bba8201233;hp=f700d013b5dc6a55f88196695b8a8ec83b2242b9;hpb=4d7f66ea28c788e12f700216b9c53af9e71b8390;p=libs%2Fgl.git diff --git a/source/texture1d.cpp b/source/texture1d.cpp index f700d013..0dc85586 100644 --- a/source/texture1d.cpp +++ b/source/texture1d.cpp @@ -1,3 +1,4 @@ +#include #include "bindable.h" #include "error.h" #include "texture1d.h" @@ -12,7 +13,9 @@ Texture1D::Texture1D(): ifmt(RGB), width(0), allocated(0) -{ } +{ + static Require _req(MSP_texture1D); +} void Texture1D::storage(PixelFormat fmt, unsigned wd) { @@ -20,6 +23,9 @@ void Texture1D::storage(PixelFormat fmt, unsigned wd) throw invalid_operation("Texture1D::storage"); if(wd==0) throw invalid_argument("Texture1D::storage"); + + if(MSP_sized_internal_formats) + fmt = get_sized_pixelformat(fmt); require_pixelformat(fmt); ifmt = fmt; @@ -31,7 +37,8 @@ void Texture1D::allocate(unsigned level) if(allocated&(1<>=1, ++level) ; - allocated |= (1<>=1, ++n) ; + return n; +} + +unsigned Texture1D::get_level_size(unsigned level) const { return width>>level; } @@ -62,5 +102,36 @@ UInt64 Texture1D::get_data_size() const return id ? width*get_pixel_size(ifmt) : 0; } + +Texture1D::Loader::Loader(Texture1D &t): + DataFile::DerivedObjectLoader(t) +{ + init(); +} + +Texture1D::Loader::Loader(Texture1D &t, Collection &c): + DataFile::DerivedObjectLoader(t, c) +{ + init(); +} + +void Texture1D::Loader::init() +{ + add("raw_data", &Loader::raw_data); + add("storage", &Loader::storage); +} + +void Texture1D::Loader::raw_data(const string &data) +{ + obj.image(0, get_base_pixelformat(obj.ifmt), UNSIGNED_BYTE, data.data()); +} + +void Texture1D::Loader::storage(PixelFormat fmt, unsigned w) +{ + if(srgb) + fmt = get_srgb_pixelformat(fmt); + obj.storage(fmt, w); +} + } // namespace GL } // namespace Msp