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 Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void *data)
+void Texture1D::image(unsigned level, PixelComponents comp, DataType type, const void *data)
{
if(width==0)
throw invalid_operation("Texture1D::image");
unsigned w = get_level_size(level);
if(ARB_texture_storage)
- return sub_image(level, 0, w, fmt, type, data);
+ return sub_image(level, 0, w, comp, type, data);
BindRestore _bind(this);
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
apply_swizzle();
}
- glTexImage1D(target, level, ifmt, w, 0, get_upload_format(fmt), type, data);
+ glTexImage1D(target, level, ifmt, w, 0, get_upload_components(comp), type, data);
allocated |= 1<<level;
if(auto_gen_mipmap && level==0)
}
}
-void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelFormat fmt, DataType type, const void *data)
+void Texture1D::sub_image(unsigned level, int x, unsigned wd, PixelComponents comp, DataType type, const void *data)
{
if(width==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)
- 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();
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
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)