X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=inline;f=source%2Fcore%2Ftexture1d.cpp;h=71c736f04da4ecb7971d22461434169445614f6b;hb=2b7f8e45e75bec30c1ea27fc0efd8286f67adc3f;hp=742857be725b4ed205b369c43d823f5b0812af14;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/core/texture1d.cpp b/source/core/texture1d.cpp index 742857be..71c736f0 100644 --- a/source/core/texture1d.cpp +++ b/source/core/texture1d.cpp @@ -22,7 +22,11 @@ Texture1D::Texture1D(): void Texture1D::storage(PixelFormat fmt, unsigned wd, unsigned lv) { if(width>0) - throw invalid_operation("Texture1D::storage"); + { + if(fmt!=format || wd!=width || (lv && lv!=levels)) + throw incompatible_data("Texture1D::storage"); + return; + } if(wd==0) throw invalid_argument("Texture1D::storage"); @@ -60,6 +64,8 @@ void Texture1D::image(unsigned level, const void *data) { if(width==0) throw invalid_operation("Texture1D::image"); + if(level>=levels) + throw out_of_range("Texture1D::image"); unsigned w = get_level_size(level); @@ -75,7 +81,7 @@ void Texture1D::image(unsigned level, const void *data) } PixelComponents comp = get_components(storage_fmt); - DataType type = get_component_type(storage_fmt); + GLenum type = get_gl_type(get_component_type(storage_fmt)); glTexImage1D(target, level, storage_fmt, w, 0, comp, type, data); allocated |= 1<=levels) + throw out_of_range("Texture1D::sub_image"); Conditional _bind(!ARB_direct_state_access, this); allocate(level); PixelComponents comp = get_components(storage_fmt); - DataType type = get_component_type(storage_fmt); + GLenum type = get_gl_type(get_component_type(storage_fmt)); if(ARB_direct_state_access) glTextureSubImage1D(id, level, x, wd, comp, type, data); else @@ -126,10 +134,7 @@ void Texture1D::image(const Graphics::Image &img, unsigned lv) unsigned w = img.get_width(); PixelFormat fmt = pixelformat_from_image(img); - if(width==0) - storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, lv); - else if(w!=width) - throw incompatible_data("Texture1D::image"); + storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, lv); image(0, img.get_pixels()); }