X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ftexture1d.cpp;fp=source%2Ftexture1d.cpp;h=24266150672a90fab1f1a5acd4fd8cb4d16f849a;hp=b50f8cf444c0c9fb1435ce97e756ffc1330b59c2;hb=9087cc0a372b9c739f15398c7a22c0a6eb5041bb;hpb=a8a04ddd95e57a8f103c04dba317addc32866689 diff --git a/source/texture1d.cpp b/source/texture1d.cpp index b50f8cf4..24266150 100644 --- a/source/texture1d.cpp +++ b/source/texture1d.cpp @@ -53,13 +53,10 @@ void Texture1D::allocate(unsigned level) allocated |= (1< _bind(!ARB_direct_state_access, this); allocate(level); - fmt = get_upload_format(fmt); + comp = get_upload_components(comp); if(ARB_direct_state_access) - glTextureSubImage1D(id, level, x, wd, fmt, type, data); + glTextureSubImage1D(id, level, x, wd, comp, type, data); else - glTexSubImage1D(target, level, x, wd, fmt, type, data); + glTexSubImage1D(target, level, x, wd, comp, type, data); if(auto_gen_mipmap && level==0) generate_mipmap(); @@ -110,13 +107,15 @@ void Texture1D::image(const Graphics::Image &img, unsigned lv, bool srgb) throw incompatible_data("Texture1D::image"); unsigned w = img.get_width(); - PixelFormat fmt = pixelformat_from_graphics(img.get_format()); + PixelFormat fmt = pixelformat_from_image(img); + PixelComponents comp = get_components(fmt); + DataType type = get_component_type(fmt); if(width==0) - storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, lv); + storage(make_pixelformat(comp, type, srgb), w, lv); else if(w!=width) throw incompatible_data("Texture1D::image"); - image(0, fmt, UNSIGNED_BYTE, img.get_data()); + image(0, comp, type, img.get_data()); } unsigned Texture1D::get_n_levels() const @@ -158,7 +157,7 @@ void Texture1D::Loader::init() void Texture1D::Loader::raw_data(const string &data) { - obj.image(0, get_base_pixelformat(obj.ifmt), UNSIGNED_BYTE, data.data()); + obj.image(0, get_components(obj.ifmt), get_component_type(obj.ifmt), data.data()); } void Texture1D::Loader::storage(PixelFormat fmt, unsigned w)