#include "clear.hpp" #include namespace gli { template inline sampler_cube::sampler_cube(texture_cube const & Texture, gli::wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) , Texture(Texture) , Convert(detail::convert::call(this->Texture.format())) , BorderColor(BorderColor) , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) { GLI_ASSERT(!Texture.empty()); GLI_ASSERT(!is_compressed(Texture.format())); GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); } template inline texture_cube const & sampler_cube::operator()() const { return this->Texture; } template inline typename sampler_cube::texel_type sampler_cube::texel_fetch(extent_type const & TexelCoord, size_type Face, size_type Level) const { GLI_ASSERT(!this->Texture.empty()); GLI_ASSERT(this->Convert.Fetch); return this->Convert.Fetch(this->Texture, TexelCoord, 0, Face, Level); } template inline void sampler_cube::texel_write(extent_type const & TexelCoord, size_type Face, size_type Level, texel_type const & Texel) { GLI_ASSERT(!this->Texture.empty()); GLI_ASSERT(this->Convert.Write); this->Convert.Write(this->Texture, TexelCoord, 0, Face, Level, Texel); } template inline void sampler_cube::clear(texel_type const & Color) { GLI_ASSERT(!this->Texture.empty()); GLI_ASSERT(this->Convert.Write); detail::clear::call(this->Texture, this->Convert.Write, Color); } template inline typename sampler_cube::texel_type sampler_cube::texture_lod(normalized_type const & SampleCoord, size_type Face, level_type Level) const { GLI_ASSERT(!this->Texture.empty()); GLI_ASSERT(std::numeric_limits::is_iec559); GLI_ASSERT(this->Filter && this->Convert.Fetch); normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x), this->Wrap(SampleCoord.y)); return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, size_type(0), Face, Level, this->BorderColor); } template inline void sampler_cube::generate_mipmaps(filter Minification) { this->generate_mipmaps(this->Texture.base_face(), this->Texture.max_face(), this->Texture.base_level(), this->Texture.max_level(), Minification); } template inline void sampler_cube::generate_mipmaps(size_type BaseFace, size_type MaxFace, size_type BaseLevel, size_type MaxLevel, filter Minification) { GLI_ASSERT(!this->Texture.empty()); GLI_ASSERT(!is_compressed(this->Texture.format())); GLI_ASSERT(this->Texture.base_face() <= BaseFace && BaseFace <= MaxFace && MaxFace <= this->Texture.max_face()); GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); detail::generate_mipmaps_2d( this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, BaseFace, MaxFace, BaseLevel, MaxLevel, Minification); } }//namespace gli