Pat
Pat

Reputation: 331

Issue with loading Images using DevIL and Visual Studio 2010

I have a question about using DevIL in VS 2010. I'm trying to load an image to apply as a texture to a sprite, but I can't seem to figure out how to add the image to project such that DevIL can find it. The call to ilLoadImage keeps returning false.

void LoadTexture(string path)
{
wstring widePath = wstring(path.begin(), path.end());
const wchar_t* pathName = widePath.c_str();
ILuint devilId = 0;
ilGenImages(1, &devilId);
ilBindImage(devilId);

if(!ilLoadImage(pathName))
{
    ILenum error = ilGetError();
    const wchar_t* errorString = iluErrorString(error);
    cout << *errorString << endl;
    exit(0);
}

iluFlipImage();

int width = ilGetInteger(IL_IMAGE_WIDTH);
int height = ilGetInteger(IL_IMAGE_HEIGHT);
int openGLId = ilutGLBindTexImage();

if(openGLId = 0)
{
    cout << "The OpenGL id was not set." << endl;
    exit(0);
}

ilDeleteImages(1, &devilId);
}

void InitializeTextures()
{
ilInit();
iluInit();
ilutInit();
ilutRenderer(ILUT_OPENGL);

LoadTexture("dungeon_textures-200413-SM.jpg");
}

Upvotes: 2

Views: 663

Answers (1)

MMMovania
MMMovania

Reputation: 31

Sorry to revive an old thread. Since you are using the wide char format, you should use the unicode build of the DevIL library; make sure to copy the correct (unicode dlls) into the project directory and see if this helps.

Upvotes: 1

Related Questions