| 0.8.0 API documentation

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

Code sample: Generating mipmaps and converting float textures to rgb9e5
1 {c++}
2 #include <gli/texture2d.hpp>
3 #include <gli/convert.hpp>
4 #include <gli/generate_mipmaps.hpp>
5
6 bool convert_rgb32f_rgb9e5(const char* FilenameSrc, const char* FilenameDst)
7 {
8 if(FilenameDst == NULL)
9 return false;
10 if(std::strstr(FilenameDst, ".dds") > 0 || std::strstr(FilenameDst, ".ktx") > 0)
11 return false;
12
13 gli::texture2d TextureSource(gli::load(FilenameSrc));
14 if(TextureSource.empty())
15 return false;
16 if(TextureSource.format() != gli::FORMAT_RGB16_SFLOAT_PACK16 && TextureSource.format() != gli::FORMAT_RGB32_SFLOAT_PACK32)
17 return false;
18
19 gli::texture2d TextureMipmaped = gli::generate_mipmaps(TextureSource, gli::FILTER_LINEAR);
20
21 gli::texture2d TextureConverted = gli::convert(TextureMipmaped, gli::FORMAT_RGB9E5_UFLOAT_PACK32);
22
23 gli::save(TextureConverted, FilenameDst);
24
25 return true;
26 }