Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: code not working

  1. #1
    Guest

    code not working

    hi
    written in VC++ as a simple text application. it is to load abmp image in opengl. it gives the following errors:


    --------------------Configuration: main - Win32 Debug--------------------
    Linking...
    main.obj : error LNK2001: unresolved external symbol _auxDIBImageLoadA@4
    Debug/main.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    main.exe - 2 error(s), 0 warning(s)


    here is the code:


    #include<stdio.h>
    #include<GL/glaux.h>
    #include<GL/glut.h>
    #include<windows.h>

    void init(void)
    {
    glClearColor(0.0,0.0,0.0,0.0);
    }

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
    }


    void reshape(int w, int h)
    {
    glViewport(0,0,(GLsizei) w,(GLsizei) h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(50.0,50.0,-50.0,-50.0,-1.0,1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

    GLuint LoadGLTexture(char *filename,int filter) // Load Bitmaps And Convert To Textures
    {
    GLuint tempadd; // Storage for one texture
    AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture

    memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL
    if (filter > 2) //Invaild filter
    {
    exit(1);
    }

    if (TextureImage[0]==auxDIBImageLoad(filename))
    {
    glGenTextures(1, &tempadd); //Setup storage
    glBindTexture(GL_TEXTURE_2D, tempadd);
    if (filter==0)
    {
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
    }

    if (filter==1)
    {
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
    }

    if (filter==2)
    {
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
    }

    if (TextureImage[0]) // If Texture Exists
    {
    if (TextureImage[0]->data) // If Texture Image Exists
    free(TextureImage[0]->data); // Free The Texture Image Memory
    free(TextureImage[0]); // Free The Image Structure
    }
    }
    return tempadd; // Return The Texture Structure

    }

    int main(int argc,char **argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(100,100);
    glutCreateWindow("Spiderman");
    init();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    GLuint newtex;
    newtex = LoadGLTexture("bubbles.bmp",2);
    glBindTexture(GL_TEXTURE_2D,newtex);
    glutMainLoop();
    return 0;
    }


    thanks a lot in advance!!!!!
    anxious yet again

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: code not working

    You probably forgot to link to glaux.lib.

    Right-click on your project in the workspace window and choose settings. Now, go to the Link tab.

    In one of the fields, you should see a lot of .lib files (these are the libraries you link to). There should be opengl32.lib for example.

    Simply add glaux.lib to the list and recompile your project: the error should be gone !

    Hope this helps.

    Regards.

    Eric

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,755

    Re: code not working

    Since you're using glut, you probably won't see opengl32.lib in the list of libraries. The glut header has lines like

    #pragma comment(lib, opengl32.lib)

    that will do the same thing as adding the libraries to the project. glAux.lib isn't one that glut.h adds, though so you will need to add that to your project. (Or use a line like the one above, but I tend to just add it to the project.)

    Also, if you add it to the project be sure to do it for both the debug and release configurations.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •