Jump to content
  • Advertisement
Sign in to follow this  
bronowski

OpenGL DevIL load image problem

This topic is 2817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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 );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!