GLI is a simple C++ image library based on OpenGL and GLSL convensions and used to load and store OpenGL textures.
GLI supports DDS (Direct3D9 and Direct3D10) file formats including all BC1 to BC7 formats but don't compressed image data to these formats (yet).
Create a texture with GLI 0.4 and save it to a DDS file:- #include <glm/glm.hpp>
- #include <gli/gli.hpp>
-
gli::texture2D Texture(1, gli::RGBA8_UNORM, gli::texture2D::dimensions_type(256, 256));
-
glm::u8vec4 * LinearAddress = Texture.data<glm::u8vec4>();
-
...
-
...
-
gli::saveStorageDDS(Texture, "texture.dds");
Create an OpenGL 4.2 texture with GLI 0.4:- #include <gli/gli.hpp>
-
gli::texture2D Texture(gli::loadStorageDDS("kueken2.dds"));
-
assert(!Texture.empty());
-
glBindTexture(GL_TEXTURE_2D, TextureName);
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(Texture.levels() - 1));
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
-
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
-
glTexStorage2D(GL_TEXTURE_2D,
-
GLint(Texture.levels()),
-
GLenum(gli::internal_format(Texture.format())),
-
GLsizei(Texture.dimensions().x),
-
GLsizei(Texture.dimensions().y));
-
if(gli::is_compressed(Texture.format()))
-
{
-
for(gli::texture2D::size_type Level = 0; Level < Texture.levels(); ++Level)
-
{
-
glCompressedTexSubImage2D(GL_TEXTURE_2D,
-
GLint(Level),
-
0, 0,
-
GLsizei(Texture[Level].dimensions().x),
-
GLsizei(Texture[Level].dimensions().y),
-
GLenum(gli::internal_format(Texture.format())),
-
GLsizei(Texture[Level].size()),
-
Texture[Level].data());
-
}
-
}
-
else
-
{
-
for(gli::texture2D::size_type Level = 0; Level < Texture.levels(); ++Level)
-
{
-
glTexSubImage2D(GL_TEXTURE_2D,
-
GLint(Level),
-
0, 0,
-
GLsizei(Texture[Level].dimensions().x),
-
GLsizei(Texture[Level].dimensions().y),
-
GLenum(gli::external_format(Texture.format())),
-
GLenum(gli::type_format(Texture.format())),
-
Texture[Level].data());
-
}
-
}
Releases:
- 10/03/2013 GLI 0.4.1.0 (ZIP, 17.6 MB) (7Z, 14.9 MB)
- 28/01/2013 GLI 0.4.0.0 (ZIP, 4.0 MB) (7Z, 2.14 MB)
- 08/02/2011 GLI 0.3.0.3 (ZIP, 3.5 MB) (7Z, 2.1 MB)
- 08/02/2011 GLI 0.3.0.2 (ZIP, 1.5 MB) (7Z, 869 KB)
- 15/10/2010 GLI 0.3.0.1 (ZIP, 35 KB) (7Z, 17 KB)
- 01/10/2010 GLI 0.3.0.0 (ZIP, 35 KB) (7Z, 18 KB)
- 07/09/2010 GLI 0.2.2.1 (ZIP, 14 KB) (7Z, 14 KB)
- 15/02/2010 GLI 0.2.1.0 (ZIP, 17 KB) (7Z, 10 KB)
- 10/01/2010 GLI 0.2.0.0 (ZIP, 17 KB) (7Z, 10 KB)
- 18/09/2009 GLI 0.1.1.0 (ZIP) (7Z)
- 28/03/2009 GLI 0.1.0.0 (ZIP) (7Z)