void Buffer::storage(unsigned sz)
{
if(size>0)
- throw invalid_operation("Buffer::storage");
+ {
+ if(sz!=size)
+ throw incompatible_data("Buffer::storage");
+ return;
+ }
if(sz==0)
throw invalid_argument("Buffer::storage");
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");
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());
}
void Texture2D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned lv)
{
if(width>0)
- throw invalid_operation("Texture2D::storage");
+ {
+ if(fmt!=format || wd!=width || ht!=height || (lv && lv!=levels))
+ throw incompatible_data("Texture2D::storage");
+ return;
+ }
if(wd==0 || ht==0)
throw invalid_argument("Texture2D::storage");
unsigned w = img.get_width();
unsigned h = img.get_height();
PixelFormat fmt = pixelformat_from_image(img);
- if(width==0)
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv);
- else if(w!=width || h!=height || (lv && lv!=levels))
- throw incompatible_data("Texture2D::image");
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv);
PixelStore pstore = PixelStore::from_image(img);
BindRestore _bind_ps(pstore);
void Texture3D::storage(PixelFormat fmt, unsigned wd, unsigned ht, unsigned dp, unsigned lv)
{
if(width>0)
- throw invalid_operation("Texture3D::storage");
+ {
+ if(fmt!=format || wd!=width || ht!=height || dp!=depth || (lv && lv!=levels))
+ throw incompatible_data("Texture3D::storage");
+ return;
+ }
if(wd==0 || ht==0 || dp==0)
throw invalid_argument("Texture3D::storage");
h = w;
PixelFormat fmt = pixelformat_from_image(img);
- if(width==0)
- 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");
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, d, lv);
PixelStore pstore = PixelStore::from_image(img);
BindRestore _bind_ps(pstore);
void TextureCube::storage(PixelFormat fmt, unsigned sz, unsigned lv)
{
if(size>0)
- throw invalid_operation("TextureCube::storage");
+ {
+ if(fmt!=format || sz!=size || (lv && lv!=levels))
+ throw incompatible_data("TextureCube::storage");
+ return;
+ }
if(sz==0)
throw invalid_argument("TextureCube::storage");
{
unsigned w = img.get_width();
unsigned h = img.get_height();
- PixelFormat fmt = pixelformat_from_image(img);
- if(size==0)
- {
- if(w!=h)
- throw incompatible_data("TextureCube::image");
-
- storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w);
- }
- else if(w!=size || h!=size)
+ if(w!=h)
throw incompatible_data("TextureCube::image");
+ PixelFormat fmt = pixelformat_from_image(img);
+ storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w);
+
PixelStore pstore = PixelStore::from_image(img);
BindRestore _bind_ps(pstore);