ilLoadImage() problem

Help
None
2011-01-09
2015-10-31
  • None

    None - 2011-01-09

    I cannot get images to load with DevIL. I have looked at previous threads and tried their solutions, but did not find them to help. I need to get this working soon, so any advice will be greatly appreciated. My current 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 is as follows:

    Start getBackgroundTexture(C:\FullMoon.jpg ) *********
    After load image - Devil Error: 1291, i
    Start getBackgroundTexture(./FullMoon.jpg ) *********
    Start - Devil Error: 1290, c
    After load image - Devil Error: 1291, i
    Start getBackgroundTexture(FullMoon.jpg ) *********
    Start  - Devil Error: 1290, c
    After load image - Devil Error: 1291, i
    

    Checking in the manual the error codes are:
    error 1290 = IL_COULD_NOT_OPEN_FILE
    error 1291 = IL_INVALID_EXTENSION

    I'm not sure why iluErrorString returns only i and c or why I am getting these errors.

    Thanks for any replies.

     
  • flipcoder

    flipcoder - 2011-02-23

    You've probably already figured this out by now but if not…
    Solution: You need to either use an older version of devil (before this bug occurred, im using 1.6.7) or use the L-prefix (L"") when passing in strings, This is a problem even for non-unicode versions. No idea why.  That's the reason you get single character error messages "i" and "c".

     
  • Plaque Attack

    Plaque Attack - 2012-01-02

    The previous post from flipcoder didn't work for me - instead, it seems you need to force-cast a const char string to const wchar_t string (in msvc 2008 +)

    Such as below:

    ilLoadImage((const ILstring) "C:\\ImageFiles\\Image.jpg")

    (ILstring is defined as wchar_t*)

     
  • Youda

    Youda - 2015-10-31

    This didn't solve the problem.
    I tried:
    1. undef _UNICODE
    2. define _UNICODE and casting to wchar_t*
    3. define _UNICODE and converting to wchar_t*
    still error 1291 (IL_INVALID_EXTENSION) after ilLoadImage

     
  • Youda

    Youda - 2015-10-31

    I would like to try some of the older versions as you suggested, but none of those until 1.7.3 will even compile, each of which with different error lol.
    This library is such a .... unfinished buggy piece of .... work. (facepalm)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks