DevIL load image problem

Started by
0 comments, last by ileonte 13 years, 3 months ago
I cannot get images to load with DevIL. I have looked at previous threads and tried their solutions, my process is as follows:

GLUT init code.

	if(ilGetInteger(IL_VERSION_NUM) < IL_VERSION ||	iluGetInteger(ILU_VERSION_NUM) < ILU_VERSION ||	ilutGetInteger(ILUT_VERSION_NUM) < ILUT_VERSION) {	printf("DevIL version mismatch.\n");}ilInit();iluInit();ilutInit();ilutRenderer(ILUT_OPENGL);ILenum devilError = ilGetError();if (devilError != IL_NO_ERROR) 	cout << "Devil Error: " << iluErrorString(devilError) << endl;GlutMainLoop();


Now the app is running and at some point I call the following function with DevIL code as follows:

GLuint getBackgroundTexture(string path, Vertex* size){		cout << "Start getBackgroundTexture(" << path << ") *********" << endl;	ILenum devilError;	devilError = ilGetError();	if (devilError != IL_NO_ERROR) 	{		cout << "Start - Devil Error: " << devilError << 			", " << iluErrorString(devilError) << endl;		}	// Load image data from image file.	ILuint imageID;	ilGenImages(1, &imageID);	devilError = ilGetError();	if (devilError != IL_NO_ERROR) 	{		cout << "After gen image - Devil Error: " << devilError << 			", " << iluErrorString(devilError) << endl;		}	ilBindImage(imageID);		devilError = ilGetError();	if (devilError != IL_NO_ERROR) 	{		cout << "After bind image - Devil Error: " << devilError << 			", " << iluErrorString(devilError) << endl;		}	if(!ilLoadImage(path.c_str()))  // This always fails	{		devilError = ilGetError();		cout << "After load image - Devil Error: " << devilError << 			", " << iluErrorString(devilError) << endl;			ilDeleteImages(1, &imageID);		return -1;	}	// Generate a texture from the image data.	GLuint openglID;	openglID   = ilutGLBindTexImage(); 	devilError = ilGetError();	if (devilError != IL_NO_ERROR) 	{		cout << "After load image - Devil Error: " << devilError << 			", " << iluErrorString(devilError) << endl;		}	// Set the image origin to the lower left.		ilEnable(IL_ORIGIN_SET);	ilOriginFunc(IL_ORIGIN_LOWER_LEFT);	if (devilError != IL_NO_ERROR) 	{		cout << "After origin set - Devil Error: " << devilError << 			", " << iluErrorString(devilError) << endl;		}	return openglID;}


The output from the iluErrorString statements is always i or c.

Any ideas would be appreciated!

Advertisement
Is there any reason you need to go through all of that instead of just using ilutGLLoadImage() ? I use it and it works just fine for me.
#include <IL/il.h>#define ILUT_USE_OPENGL#include <IL/ilut.h>GLuint tex = ilutGLLoadImage( file_name );

This topic is closed to new replies.

Advertisement