Unofficial OpenGL Software Development Kit: GL Image

Unofficial OpenGL Software Development Kit 0.5.0

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Modules
GL Image

##

The GL Image library is the Unofficial OpenGL SDK library for loading images from files and memory, and converting them into OpenGL textures.

The GL Image library is distributed under the MIT License.

GL Image is used for two things: loading images into memory and converting those memory images into OpenGL texture objects. This creates three basic divisions in GL Image.

The functions responsible for loading image formats from disk (or from memory) are called loaders. They are all in the glimg::loaders namespace. There are several loaders available, for various different image file formats. Each kind of loader has its own namespace within the loaders namespace.

The loaded representation of an image file is the glimg::ImageSet object. An glimg::ImageSet, as the name implies, represents multiple images. This allows support for file formats like DDS or KTX that store mipmaps, texture arrays, and/or cubemap faces all within the same file. The image set object and its associated types are used to query information about each image within the set.

The images within an glimg::ImageSet can be directly loaded into an OpenGL texture by using the various texture creation functions. Note that use of these functions requires that you use GL Load to initialize your OpenGL context. They also require that a valid OpenGL context is bound.

Basic use of the library is quite simple. The `<glimg/glimg.h>` header contains all of the important components of the library. To load an image, select a loader and use its loading function to load the texture into an glimg::ImageSet object. Then pass this glimg::ImageSet along to glimg::CreateTexture to create the OpenGL texture object for the file.

Here is an example:

#include <memory>
#include <glload/gl_all.h>
#include <glload/gll.hpp>
#include <glimg/glimg.h>
int main(int argc, char *argv[])
{
//Initialize OpenGL and bind the context
//glload must be initialized for glimg texture creation to work.
if(glload::LoadFunctions() == glload::LS_LOAD_FAILED)
//exit in some way
//Loading succeeded. Now load a texture.
GLuint theTexture = 0;
try
{
std::auto_ptr<glimg::ImageSet> pImgSet(glimg::loaders::stb::LoadFromFile("filename.png"));
theTexture = glimg::CreateTexture(pImgSet.get(), 0);
}
catch(glimg::loaders::stb::StbLoaderException &e)
{
//Image file loading failed.
}
catch(glimg::TextureGenerationException &e)
{
//Texture creation failed.
}
//Texture loaded successfully.
}

## Modules

| Image Loaders
| Functions for loading image files into ImageSet objects.
| ImageSet
| Classes for representing image data.
| Texture Creation
| Functions to build textures from ImageSet objects.
| Image Creation
| Manual ImageSet creation classes.
| Exceptions
| Exceptions thrown by GL Image functions and operations.