X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture1d.cpp;h=a0ab79b943aef573e192edcc36e1e011fffb77c7;hb=ccbfdfa0d9d796244b1ecc0fa3faa2c50304811b;hp=bcebca49565131eb738ba471af992cbe0e05c1a9;hpb=744dced516f11d072dc6176fdf2df7e464b9782e;p=libs%2Fgl.git diff --git a/source/texture1d.cpp b/source/texture1d.cpp index bcebca49..a0ab79b9 100644 --- a/source/texture1d.cpp +++ b/source/texture1d.cpp @@ -1,3 +1,4 @@ +#include #include "bindable.h" #include "error.h" #include "texture1d.h" @@ -9,9 +10,12 @@ namespace GL { Texture1D::Texture1D(): Texture(GL_TEXTURE_1D), + ifmt(RGB), width(0), allocated(0) -{ } +{ + static Require _req(MSP_texture1D); +} void Texture1D::storage(PixelFormat fmt, unsigned wd) { @@ -30,7 +34,8 @@ void Texture1D::allocate(unsigned level) if(allocated&(1<>=1, ++level) ; allocated |= (1<>level; } +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