X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture3d.cpp;h=667f8c31c1ede8dfe9c1896159eaa263385738be;hb=635e5dc;hp=010609a8e7a098c092524366990a9057efba1986;hpb=9087cc0a372b9c739f15398c7a22c0a6eb5041bb;p=libs%2Fgl.git diff --git a/source/texture3d.cpp b/source/texture3d.cpp index 010609a8..667f8c31 100644 --- a/source/texture3d.cpp +++ b/source/texture3d.cpp @@ -40,7 +40,7 @@ void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, if(wd==0 || ht==0 || dp==0) throw invalid_argument("Texture3D::storage"); - set_internal_format(fmt); + set_format(fmt); width = wd; height = ht; depth = dp; @@ -62,17 +62,17 @@ void Texture3D::allocate(unsigned level) { Conditional _bind(!ARB_direct_state_access, this); if(ARB_direct_state_access) - glTextureStorage3D(id, levels, ifmt, width, height, depth); + glTextureStorage3D(id, levels, storage_fmt, width, height, depth); else - glTexStorage3D(target, levels, ifmt, width, height, depth); + glTexStorage3D(target, levels, storage_fmt, width, height, depth); apply_swizzle(); allocated |= (1< _bind(!ARB_direct_state_access, this); allocate(level); - comp = get_upload_components(comp); + PixelComponents comp = get_components(storage_fmt); + DataType type = get_component_type(storage_fmt); if(ARB_direct_state_access) glTextureSubImage3D(id, level, x, y, z, wd, ht, dp, comp, type, data); else @@ -120,7 +131,14 @@ void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsi generate_mipmap(); } -void Texture3D::image(const Graphics::Image &img, unsigned lv, bool srgb) +void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsigned ht, unsigned dp, PixelComponents comp, DataType type, const void *data) +{ + if(comp!=get_components(format) || type!=get_component_type(format)) + throw incompatible_data("Texture3D::sub_image"); + sub_image(level, x, y, z, wd, ht, dp, data); +} + +void Texture3D::image(const Graphics::Image &img, unsigned lv) { unsigned w = img.get_width(); unsigned h = img.get_height(); @@ -142,17 +160,15 @@ void Texture3D::image(const Graphics::Image &img, unsigned lv, bool srgb) } PixelFormat fmt = pixelformat_from_image(img); - PixelComponents comp = get_components(fmt); - DataType type = get_component_type(fmt); if(width==0) - storage(make_pixelformat(comp, type, srgb), w, h, d, lv); + storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, d, lv); else if(w!=width || h!=height || d!=depth) throw incompatible_data("Texture3D::load_image"); PixelStore pstore = PixelStore::from_image(img); BindRestore _bind_ps(pstore); - image(0, comp, type, img.get_data()); + image(0, img.get_data()); } unsigned Texture3D::get_n_levels() const @@ -182,7 +198,7 @@ void Texture3D::get_level_size(unsigned level, unsigned &w, unsigned &h, unsigne UInt64 Texture3D::get_data_size() const { - return id ? width*height*depth*get_pixel_size(ifmt) : 0; + return id ? width*height*depth*get_pixel_size(storage_fmt) : 0; } @@ -207,7 +223,7 @@ void Texture3D::Loader::init() void Texture3D::Loader::raw_data(const string &data) { - obj.image(0, get_components(obj.ifmt), get_component_type(obj.ifmt), data.data()); + obj.image(0, data.data()); } void Texture3D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h, unsigned d)