X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture1d.cpp;h=ed7d8f6e2b877fd4f660d71dbdc72874ef3de34b;hb=194f960f91041ebee44e2745627d5e480e893d82;hp=f700d013b5dc6a55f88196695b8a8ec83b2242b9;hpb=4d7f66ea28c788e12f700216b9c53af9e71b8390;p=libs%2Fgl.git diff --git a/source/texture1d.cpp b/source/texture1d.cpp index f700d013..ed7d8f6e 100644 --- a/source/texture1d.cpp +++ b/source/texture1d.cpp @@ -1,3 +1,5 @@ +#include +#include #include "bindable.h" #include "error.h" #include "texture1d.h" @@ -12,7 +14,9 @@ Texture1D::Texture1D(): ifmt(RGB), width(0), allocated(0) -{ } +{ + static Require _req(MSP_texture1D); +} void Texture1D::storage(PixelFormat fmt, unsigned wd) { @@ -20,6 +24,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 +38,18 @@ 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 +119,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