image loading

Im trying to decide which image loading library to use with OpenGL. I found several online such as DevIL and SOIL. I was wondering what everyone here is using.

DevIL and SOIL are certainly a good place to start. I’m using imagemagick myself, it’s cross-platform and supports virtually all file formats. On the other hand, it doesn’t provide an OpenGL interface.


NiCo do you have to compile imagemagick to use Magick++. I downloaded the imagemagick binary package and did not see any c++ header files.

You don’t have to compile it if you installed the binary package. The header files are in c:/Program Files/ImageMagick-6.3.8-1-Q8/include


ifl from Silicon Graphics is also a nice package. I found it a bit easier to use and get started with than ImageMagick.

NiCo do you know where i can find an example of how to use imagemagick with opengl.

Image im;"test.bmp");

int w = im.columns();
int h = im.rows();

unsigned char* data = new unsigned char[w*h];


delete[] data;


Nico thanks, I’ll try it out.

NiCo I know this is not an Opengl question but can you help, I am getting link errors while compiling my code using Dev-C++. The error shows undefined reference to Magick::Image::Image() while compiling.

I include the namespace for it and (using namespace Magick;)
I tried linking the following files


but no luck. I also try initializing Magick++ with the following lines of code.

InitializeMagick(“C://Program Files/ImageMagick-6.3.8-Q16/”);

and still no luck. Any suggestion?

Why not FreeImage? Is open source but you can use It for commercial purposes, and now supports HDR images!( OpenEXR and Radiance):

Some sample code:

///Now the interesting code:
FREE_IMAGE_FORMAT formato = FreeImage_GetFileType(textureFile,0);//Automatocally detects the format(from over 20 formats!)
	FIBITMAP* imagen = FreeImage_Load(formato, textureFile);
	FIBITMAP* temp = imagen;
	imagen = FreeImage_ConvertTo32Bits(imagen);
	int w = FreeImage_GetWidth(imagen);
	int h = FreeImage_GetHeight(imagen);
	cout<<"The size of the image is: "<<textureFile<<" es "<<w<<"*"<<h<<endl; //Some debugging code
	GLubyte* textura = new GLubyte[4*w*h];
	char* pixeles = (char*)FreeImage_GetBits(imagen);
	//FreeImage loads in BGR format, so you need to swap some bytes(Or use GL_BGR).
	for(int j= 0; j<w*h; j++){
		textura[j*4+0]= pixeles[j*4+2];
		textura[j*4+1]= pixeles[j*4+1];
		textura[j*4+2]= pixeles[j*4+0];
		textura[j*4+3]= pixeles[j*4+3];
		//cout<<j<<": "<<textura[j*4+0]<<"**"<<textura[j*4+1]<<"**"<<textura[j*4+2]<<"**"<<textura[j*4+3]<<endl;
	//Now generate the OpenGL texture object 
	glGenTextures(1, &texturaID);
	glBindTexture(GL_TEXTURE_2D, texturaID);
	glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA, w, h, 0, GL_RGBA,GL_UNSIGNED_BYTE,(GLvoid*)textura );
	GLenum huboError = glGetError();
		cout<<"There was an error loading the texture"<<endl;


FreeImage is cross plataform too! and comeswoth a lot of doc. ALso have some functions utilities to save Files, format change rotate, sclae images and tone mapping!

By the way, which format do you use for HDR Cube Maps?, and where is a gallery of these CubeMaps?(others than the ones from I need it works on Linux.

A thread in french, have a look at all the links on the 3 pages, it has quite a lot of cubemap and skies galleries :…der=ASC&start=0

There are more HDR probes here:

Personally, I use the format described in EXT_texture_shared_exponent to store my cubemaps.