Home

Awesome

gli

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:

For more information about GLI, please have a look at the manual and the API reference documentation. The source code and the documentation are licensed under the Happy Bunny License (Modified MIT) or the MIT License.

Thanks for contributing to the project by submitting pull requests.

#include <gli/gli.hpp>

GLuint CreateTexture(char const* Filename)
{
	gli::texture Texture = gli::load(Filename);
	if(Texture.empty())
		return 0;

	gli::gl GL(gli::gl::PROFILE_GL33);
	gli::gl::format const Format = GL.translate(Texture.format(), Texture.swizzles());
	GLenum Target = GL.translate(Texture.target());
	assert(gli::is_compressed(Texture.format()) && Target == gli::TARGET_2D);

	GLuint TextureName = 0;
	glGenTextures(1, &TextureName);
	glBindTexture(Target, TextureName);
	glTexParameteri(Target, GL_TEXTURE_BASE_LEVEL, 0);
	glTexParameteri(Target, GL_TEXTURE_MAX_LEVEL, static_cast<GLint>(Texture.levels() - 1));
	glTexParameteriv(Target, GL_TEXTURE_SWIZZLE_RGBA, &Format.Swizzles[0]);
	glTexStorage2D(Target, static_cast<GLint>(Texture.levels()), Format.Internal, Extent.x, Extent.y);
	for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
	{
		glm::tvec3<GLsizei> Extent(Texture.extent(Level));
		glCompressedTexSubImage2D(
			Target, static_cast<GLint>(Level), 0, 0, Extent.x, Extent.y,
			Format.Internal, static_cast<GLsizei>(Texture.size(Level)), Texture.data(0, 0, Level));
	}

	return TextureName;
}

Lastest release

Project Health

ServiceSystemCompilerStatus
Travis CILinux 64 bitsClang 3.9, Clang 7, Clang 9, Clang 10, GCC 4.8, GCC 7.4, GCC 9, GCC 10Travis CI
AppVeyorWindows 32 and 64Visual Studio 2013AppVeyor

Release notes

GLI 0.8.3.0 - 2017-XX-XX

Features:

Fixes:


GLI 0.8.2.0 - 2016-11-13

Features:

Improvements:

Fixes:


GLI 0.8.1.1 - 2016-09-11

Improvements:

Fixes:


GLI 0.8.1.0 - 2016-03-16

Features:

Improvements:

Fixes:


GLI 0.8.0.0 - 2016-02-16

Features:

Improvements:

Fixes:

Work in progress:


GLI 0.7.0.0 - 2015-09-01


GLI 0.6.1.1 - 2015-07-18


GLI 0.6.1.0 - 2015-07-18


GLI 0.6.0.0 - 2015-06-28


GLI 0.5.1.1 - 2014-01-20


GLI 0.5.1.0 - 2014-01-18


GLI 0.5.0.0 - 2013-11-24


GLI 0.4.1.0: 2013-03-10


GLI 0.4.0.0: 2013-01-28


GLI 0.3.0.3: 2011-04-05


GLI 0.3.0.2: 2011-02-08


GLI 0.3.0.1: 2010-10-15


GLI 0.3.0.0: 2010-10-01


GLI 0.2.2.0: 2010-09-07


GLI 0.2.1.1: 2010-05-12


GLI 0.2.1.0: 2010-02-15


GLI 0.2.0.0: 2010-01-10


GLI 0.1.1.0: 2009-09-18


GLI 0.1.0.0: 2009-03-28