allocated |= (1<<levels)-1;
}
else
- {
- PixelFormat base_fmt = get_base_pixelformat(ifmt);
- image(level, base_fmt, get_alloc_type(base_fmt), 0);
- }
+ image(level, get_components(ifmt), get_component_type(ifmt), 0);
}
-void Texture3D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
+void Texture3D::image(unsigned level, PixelComponents comp, DataType type, const void *data)
{
if(width==0 || height==0 || depth==0)
throw invalid_operation("Texture3D::image");
get_level_size(level, w, h, d);
if(ARB_texture_storage)
- return sub_image(level, 0, 0, 0, w, h, d, fmt, type, data);
+ return sub_image(level, 0, 0, 0, w, h, d, comp, type, data);
BindRestore _bind(this);
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
apply_swizzle();
}
- glTexImage3D(target, level, ifmt, width, height, depth, 0, get_upload_format(fmt), type, data);
+ glTexImage3D(target, level, ifmt, width, height, depth, 0, get_upload_components(comp), type, data);
allocated |= 1<<level;
if(auto_gen_mipmap && level==0)
}
}
-void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsigned ht, unsigned dp, PixelFormat fmt, DataType type, const void *data)
+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(width==0 || height==0 || depth==0)
throw invalid_operation("Texture3D::image");
Conditional<BindRestore> _bind(!ARB_direct_state_access, this);
allocate(level);
- fmt = get_upload_format(fmt);
+ comp = get_upload_components(comp);
if(ARB_direct_state_access)
- glTextureSubImage3D(id, level, x, y, z, wd, ht, dp, fmt, type, data);
+ glTextureSubImage3D(id, level, x, y, z, wd, ht, dp, comp, type, data);
else
- glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);
+ glTexSubImage3D(target, level, x, y, z, wd, ht, dp, comp, type, data);
if(auto_gen_mipmap && level==0)
generate_mipmap();
h = w;
}
- 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, h, d, lv);
+ storage(make_pixelformat(comp, type, srgb), 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, fmt, UNSIGNED_BYTE, img.get_data());
+ image(0, comp, type, img.get_data());
}
unsigned Texture3D::get_n_levels() const
void Texture3D::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 Texture3D::Loader::storage(PixelFormat fmt, unsigned w, unsigned h, unsigned d)