GLM GLI
0.8.1 0.8.0 0.7.0 0.6.1 0.6.0

OpenGL Image

Effective texture loading, access and processing.

A C++ image library based on OpenGL conventions



OpenGL Image (GLI) is a header only C++ image library for graphics software. *GLI* provides classes and functions to load image files (KTX and (DDS), facilitate graphics APIs texture creation, compare textures, access texture texels, sample textures, convert textures, generate mipmaps, etc.

This library works perfectly with OpenGL or Vulkan but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (raytracing / rasterisation), image processing, image based software testing or any development context that requires a simple and convenient image library.

  • GLI is written in C++11. It is a platform independent library with no dependence and it supports the following compilers:
  • Apple Clang 4.0 and higher
  • GCC 4.6 and higher
  • Intel C++ Composer XE 2013 and higher
  • LLVM 3.2 and higher
  • Visual Studio 2010 and higher
  • Any conform C++11 compiler

For more information about GLI, please have a look at the API reference documentation.

The source code and the documentation, including this manual, are licensed under the Happy Bunny License (Modified MIT) or the MIT License.

Thanks for contributing to the project by submitting issues for bug reports and feature requests. Any feedback is welcome at gli@g-truc.net.

Code sample, converting a RGB32F texture loaded from KTX or DDS file into a RGB9E5 texture and save it:
  • #include <gli/texture2d.hpp>
  • #include <gli/convert.hpp>
  • #include <gli/generate_mipmaps.hpp>
  • #include <gli/load.hpp>
  • #include <gli/save.hpp>
  • bool convert_rgb32f_rgb9e5(char const* FilenameSrc, char const* FilenameDst)
  • {
  • if(FilenameDst == nullptr)
  • return false;
  • if(std::strstr(FilenameDst, ".dds") > 0 || std::strstr(FilenameDst, ".ktx") > 0)
  • return false;
  • gli::texture2d TextureSource(gli::load(FilenameSrc));
  • if(TextureSource.empty())
  • return false;
  • if(TextureSource.format() != gli::FORMAT_RGB16_SFLOAT_PACK16 && TextureSource.format() != gli::FORMAT_RGB32_SFLOAT_PACK32)
  • return false;
  • gli::texture2d TextureMipmaped = gli::generate_mipmaps(TextureSource, gli::FILTER_LINEAR);
  • gli::texture2d TextureConverted = gli::convert(TextureMipmaped, gli::FORMAT_RGB9E5_UFLOAT_PACK32);
  • gli::save(TextureConverted, FilenameDst);
  • return true;
  • }