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");
{
if(width==0)
throw invalid_operation("Texture1D::image");
+ if(level>=levels)
+ throw out_of_range("Texture1D::image");
unsigned w = get_level_size(level);
}
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<<level;
void Texture1D::sub_image(unsigned level, int x, unsigned wd, const void *data)
{
if(width==0)
- throw invalid_operation("Texture3D::image");
+ throw invalid_operation("Texture1D::sub_image");
+ if(level>=levels)
+ throw out_of_range("Texture1D::sub_image");
Conditional<BindRestore> _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
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());
}