Trouble loading images

Help
jedij
2007-11-30
2013-05-02
  • jedij
    jedij
    2007-11-30

    im working in vs2005 and using DevIL with OpenGL to load images and im having trouble loading them. can anyone help me Hes the code below.

    void SetupOpenGL(void)
    {

       glEnable(GL_DEPTH_TEST);
       glEnable(GL_CULL_FACE);
       glFrontFace(GL_CCW);   
       glCullFace(GL_BACK);  

       
       ilInit();
       iluInit();
       ilEnable(IL_ORIGIN_SET);
       ilOriginFunc(IL_ORIGIN_LOWER_LEFT);
       ilEnable(IL_TYPE_SET);
       ilTypeFunc(IL_UNSIGNED_BYTE);
       ilEnable(IL_FORMAT_SET);
       ilFormatFunc(IL_RGB);

       ilutRenderer(ILUT_OPENGL);
       texid =0;
       ilGenImages(1,&texid);
       ilBindImage(texid);
       
       success = ilLoadImage(L"airfield2.jpg");

       if(success)
       {
            success = ilConvertImage(IL_RGB,IL_UNSIGNED_BYTE);

            //i would like to use these functions but i dont real know how.
        //ilutGLBindTexImage();
        //ilutGLBuildMipmaps();
        //ilutGLBindMipmaps();
        glGenTextures(1,&image);
        glBindTexture(GL_TEXTURE_2D,image);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
        glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
        ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT),GL_UNSIGNED_BYTE,ilGetData());
        }
        else
        MessageBox(NULL, L"Cant load", L"Cant load", MB_OK);
        return;

        m_airfieldList = glGenLists(1);   
        glNewList(m_airfieldList,GL_COMPILE);
        float box_size = 10;
       
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex3f(-box_size, -box_size,  0.0f);   
        glTexCoord2f(1.0f, 0.0f); glVertex3f( box_size, -box_size,  0.0f);   
        glTexCoord2f(1.0f, 1.0f); glVertex3f( box_size,  box_size,  0.0f);   
        glTexCoord2f(0.0f, 1.0f); glVertex3f(-box_size,  box_size,  0.0f);   
        glEnd();

        glEndList();
       
        ilDeleteImages(1,&texid);
        glDeleteTextures(1, &image);
    }