Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Beginner help: .JPG to OpenGL

project6
2008-07-23
2013-05-02
  • project6
    project6
    2008-07-23

    Hi

    I have a function that accepts an array of GLuints, I want to read x .JPGs into this array.
    My function gets called in a for loop, so far it looks like this.

    [code]
        ILuint imageName;
        GLuint image;
        ILboolean success;

        // Error check
        if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION)
        {
            return;
        }

        // Initialization
        ilInit();
        iluInit();
        ilutRenderer(ILUT_OPENGL);

        ilGenImages(1, &imageName);        // grab a new image name
        ilBindImage(imageName);            // bind it

        // Conversion from Cstring to char*
        char* pFileName = fileName->GetBuffer();

        eX3D::g_data.textures[i] = ilutGLLoadImage( pFileName );
    [/code]

    But it's not working, ilutGLLoadImage returns 0. Is this the right approach to fill up my GLuint array?

    /p6

     
    • Nicolas Weber
      Nicolas Weber
      2008-07-31

      You should not call ilInit(), iluInit() or ilutRenderer() in a loop, only once at application startup. Be sure to call them only after your OpenGL context is set up (this is important, it's likely the cause of your problem). You don't need the calls to ilGenImages() and ilBindImage() if you use ilutGLLoadImage().