OpenGL Image (GLI) is a header only C++ image library for graphics software released under the MIT license.
For more information about GLI, please have a look at the API reference documentation.
This library works perfectly with OpenGL but it also ensures interoperability with other third party libraries and SDK. It is a good candidate for software rendering (raytracing / rasterisation), image processing, physic simulations and any development context that requires a simple and convenient mathematics 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 C++ 2012 and higher
- Any conform C++11 compiler
Thanks for contributing to the project by submitting issues for bug reports and feature requests. Any feedback is welcome at gli@g-truc.net.
#include <gli/gli.hpp>
GLuint CreateTextureArray(char const* Filename)
{
gli::texture2D Texture(gli::load_dds(Filename));
assert(!Texture.empty());
gli::gl GL;
gli::gl::format const Format = GL.translate(Texture.format());
GLint const MaxLevels = static_cast<GLint>(Texture.levels() - 1);
GLuint TextureName = 0;
glGenTextures(1, &TextureName);
glBindTexture(GL_TEXTURE_2D_ARRAY, TextureName);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, MaxLevels);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_R, Format.Swizzle[0]);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_G, Format.Swizzle[1]);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_B, Format.Swizzle[2]);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_A, Format.Swizzle[3]);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, static_cast<GLint>(Texture.levels()),
Format.Internal,
static_cast<GLsizei>(Texture.dimensions().x),
static_cast<GLsizei>(Texture.dimensions().y),
static_cast<GLsizei>(1));
if(gli::is_compressed(Texture.format()))
{
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, static_cast<GLint>(Level),
0, 0, 0,
static_cast<GLsizei>(Texture[Level].dimensions().x),
static_cast<GLsizei>(Texture[Level].dimensions().y),
static_cast<GLsizei>(1),
Format.External,
static_cast<GLsizei>(Texture[Level].size()),
Texture[Level].data());
}
}
else
{
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, static_cast<GLint>(Level),
0, 0, 0,
static_cast<GLsizei>(Texture[Level].dimensions().x),
static_cast<GLsizei>(Texture[Level].dimensions().y),
static_cast<GLsizei>(1),
Format.External, Format.Type,
Texture[Level].data());
}
}
return TextureName;
}
Service | System | Compiler | Status |
---|---|---|---|
Drone | Linux 64 bits | GCC 4.6.3 |
- Fixed GCC
- Fixed warnings
- Fixed saved DDS header size on #52
- Updated API documentation
- Fixed link error
- Fixed interface inconsistencies
- Improved clear(), data() and size() performance using caching
- Removed internal dependence to std::fstream
- Added FORMAT_BGRX8_UNORM and FORMAT_BGRX8_SRGB support #48, #43
- Improved FORMAT_RGB8_UNORM loading
- Large refactoring
- Added loading DDS from memory
- Added saving DDS to memory
- Improved DDS coverage for R, RG, RGB and RGBA formats
- Added DDS ASTC, PVRTC, ATC and ETC support
- Added DDS alpha, luminance and alpha luminance support
- Added PVRTC2, ETC2 and EAC formats
- Fixed swizzled RGB channel when reading back a DDS
- Fixed getMask* link error
- Added flip function
- Added level_count function
- Fixed interaction with std::map (#33)
- Added texelFetch and texelWrite functions
- Essencially a rewrite of the library
- Added explicit copies
- Added single memory allocation per texture storage
- Added texture views
- Added texture copies
- Added comparison operators
- Added clear
- Added DDS saving
- Fixed GCC build
- Fixed XCode build
- Large API refactoring
- Performance improvements at loading: 50x in debug and 50% in release build
- Added texture2DArray
- Added textureCube and textureCubeArray
- Added texture3D
- Added texture1D and texture1DArray
- Improved DDS loading support
- Fixed bugs
- Fixed bugs
- Fixed bugs
- Added DDS10 load and store (BC1 - BC7)
- Added extension system
- Added automatic OpenGL texture object creation from file
- Added DDS exporter
- Fixed GCC build
- Added texelWrite function
- Fixed Visual Studio 2010 warnings
- Added readme.txt and copying.txt
- Updated API
- Removed Boost dependency
- Fixed DDS loader
- Added RGB8 to DDS loader
- Added component swizzle operation
- Added 32 bits integer components support
- Fixed texel fetch
- Added TGA loader
- Added DDS loader
- Added duplicate, crop, partial copy
- Added mipmaps generation.