Menu

RT: Getting Started With GLUT/OpenGL

Wayne Keen
2004-03-07
2012-09-26
<< < 1 2 3 (Page 3 of 3)
  • David Bierbaum

    David Bierbaum - 2005-01-30

    ... or you might try FreeGLUT instead. It's in the devpaks.org webupdate site as well...

     
  • Nobody/Anonymous

    ok this is getting a lil unbelievable for me. I dont anymore get the code.o(.eh_frame+0x11):code.c: undefined reference to `__gxx_personality_v0' error but i gte 17 new ones. N whats shocking is that i made no change to the code nothing. I just close the stuff up n open the same next day i get 17 errors.

    Compiler: Default compiler
    Building Makefile: "C:\Dev-Cpp\Makefile.win"
    Executing make...
    make.exe -f "C:\Dev-Cpp\Makefile.win" all
    g++.exe -DDEBUG E:/Resource/game_assignment_icat/code.o -o "walkthru.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib" -lglut32 -lopengl32 -lglu32 -lgmon -pg -lobjc -g3 -s

    E:/Resource/game_assignment_icat/code.o(.text+0xa15): In function Z6teapotPKff': E:/Resource/game_assignment_icat/code.c:134: undefined reference toglRotated@16'
    E:/Resource/game_assignment_icat/code.o(.text+0xa9e):E:/Resource/game_assignment_icat/code.c:139: undefined reference to glutSolidTeapot@4' E:/Resource/game_assignment_icat/code.o(.text+0xb3e): In functionZ13coloured_cubePKff':

    E:/Resource/game_assignment_icat/code.c:150: undefined reference to glutSolidCube@4' E:/Resource/game_assignment_icat/code.o(.text+0xd41): In functionZ7displayv':
    E:/Resource/game_assignment_icat/code.c:180: undefined reference to glTranslated@12' E:/Resource/game_assignment_icat/code.o(.text+0xd93):E:/Resource/game_assignment_icat/code.c:185: undefined reference toglRotated@16'
    E:/Resource/game_assignment_icat/code.o(.text+0xdb5):E:/Resource/game_assignment_icat/code.c:186: undefined reference to glTranslated@12' E:/Resource/game_assignment_icat/code.o(.text+0xdec):E:/Resource/game_assignment_icat/code.c:190: undefined reference toglTranslated@12'

    E:/Resource/game_assignment_icat/code.o(.text+0xe40):E:/Resource/game_assignment_icat/code.c:198: undefined reference to glTranslated@12' E:/Resource/game_assignment_icat/code.o(.text+0xf31): In functionZ7reshapeii':
    E:/Resource/game_assignment_icat/code.c:225: undefined reference to gluPerspective@16' E:/Resource/game_assignment_icat/code.o(.text+0x1127): In functionZ8keyboardhii':
    E:/Resource/game_assignment_icat/code.c:238: undefined reference to glTranslated@12' E:/Resource/game_assignment_icat/code.o(.text+0x1153):E:/Resource/game_assignment_icat/code.c:242: undefined reference toglTranslated@12'

    E:/Resource/game_assignment_icat/code.o(.text+0x117f):E:/Resource/game_assignment_icat/code.c:246: undefined reference to glTranslated@12' E:/Resource/game_assignment_icat/code.o(.text+0x11ab):E:/Resource/game_assignment_icat/code.c:250: undefined reference toglTranslated@12'
    E:/Resource/game_assignment_icat/code.o(.text+0x11e0):E:/Resource/game_assignment_icat/code.c:254: undefined reference to glRotated@16' E:/Resource/game_assignment_icat/code.o(.text+0x1215):E:/Resource/game_assignment_icat/code.c:258: undefined reference toglRotated@16'
    E:/Resource/game_assignment_icat/code.o(.text+0x1277):E:/Resource/game_assignment_icat/code.c:262: undefined reference to gluLookAt@36' E:/Resource/game_assignment_icat/code.o(.text+0x1666): In functionmain':
    E:/Resource/game_assignment_icat/code.c:347: undefined reference to `gluPerspective@16'

    make.exe: *** [walkthru.exe] Error 1

    Execution terminated

    Now whats this? I've tried removing dev-cpp n reinstalling it like over 5 times now. Still no help. The same bit of code works with the same dev-cpp version and the same glut lib's at home. But why not at work?

    Rouge

     
    • Wayne Keen

      Wayne Keen - 2005-01-31

      Where did you get Glut from, and where did you put things?

      Also, why are you using an option to link Objective C code? That makes no sense in the current context.

      Wayne

       
      • Wayne Keen

        Wayne Keen - 2005-01-31

        I tell you what. Lets start at the beginning, so I get things straight about you and your setup.

        Start a new thread please.

        Give me the basic 3 pieces of information about your setup, plus, step by step, what you did to get and install Glut.

        Wayne

        p.s. The basic 3, in case you need to know, are talked about in the thread in the forum FAQ on question asking.

        When the going gets tough, and you are tempted to get frustrated and mad, thats when you slow down and get more methodical. OK?

         
  • Nobody/Anonymous

    I got the Glut files frm opengl.org n also got the ones frm the link u've given in the first post. Also anotehr strange occurance. Now i dont get anymore errors during compilation but get this

    The procedure entry point __glutCreateMenuWithExit could not be loacted in the dynamic link library glut32.dll. Even once be4 i got this error n then when i closed the project and opened it i got the 17 errors. So i tried again to get the 17 errors. But i dont anymore. This is really quite strange. How can this happen? Coz i gave the glut files to my frnd and this same code n told him where each files goes n it works perfectly alrite for him. I have not altered anythign inside the project as well. Thanx for ur patience.

    (Ps: I couldnt start a new thread sorry. I've bookmared this page n to start a new 1 i need to go to forums again etc... a lil lazy)

     
  • Nobody/Anonymous

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Documents and Settings\d3d\My Documents\testGL.cpp" -o "C:\Documents and Settings\d3d\My Documents\testGL.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lglut32 -lopengl32 -g3
    C:\DOCUME~1\d3d\LOCALS~1\Temp/ccO8aaaa.o(.text+0x6bb): In function Z7Displayv': C:/Documents and Settings/d3d/My Documents/testGL.cpp:144: undefined reference togluLookAt@72'
    C:\DOCUME~1\d3d\LOCALS~1\Temp/ccO8aaaa.o(.text+0x73e): In function Z7Reshapeii': C:/Documents and Settings/d3d/My Documents/testGL.cpp:161: undefined reference togluPerspective@32'
    C:\DOCUME~1\d3d\LOCALS~1\Temp/ccO8aaaa.o(.text+0x76d):C:/Documents and Settings/d3d/My Documents/testGL.cpp:163: undefined reference to `gluPerspective@32'
    collect2: ld returned 1 exit status

    Execution terminated

    Ive done all the settings right :(

     
  • Nobody/Anonymous

    Ah never mind, I got it, I had to also include "-lglu32" in the link options

    thanks for all the info

     
  • Nobody/Anonymous

    DEAR FRIENDS,

    PLEASE LINK GL AND GLUT LIBRARIES USING -lglut32 -lopengl32
    PARAMETERS IN THE PROJECT OPTIONS.
    AND PLEASE DO NOT ASK THE SAME SHIT FOR A THOUSAND TIMES !!!!!!!

     
  • Nobody/Anonymous

    lol

    Mike

     
  • Nobody/Anonymous

    I'm writing a program that draws a checkerboard, then uses the mouse callback to place checkers on the checkerboard at the location of the mouse click.

    I'm having a couple of problems with this. The most major problem is that when I rendered the checkerboard, the individual "squares" that make up the checkerboard are not squares. I give GL_POLYGON 4 vertices, and it gives me something that has five sides. and these are repeated 64 times to create a checkerboard of five-sided shapes. I've spent numerous hours trying to fix this, and I can't figure it out.Has anyone else had this sort of problem, and can you look at my code and see if there's something I'm missing that makes it do this? (the checkerboard is drawn in the display() method):

    include <GL/glut.h>

    include <stdlib.h>

    include <windows.h>

    include <math.h>

    double wheight = 800.0, wwidth = 800.0;
    double x, y, radius;
    double red, green, blue;
    int i, j;
    int clicks = 0;
    int k = 0;
    int checkers[8][8]; / holds the place of checkers and colors of checkers on the board /

    void myinit(void)
    {
    glClearColor(0.8, 0.8, 0.9, 1.0); / pale blue background /

     /* set up viewing */
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(-wwidth/2.0, wwidth/2.0, -wheight/2.0, wheight/2.0);
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
    
     /* init circle parameters */
     radius = 32.0;
    

    }

    void drawChecker(GLfloat x, GLfloat y, GLfloat r)
    {
    double theta, cx, cy, newx, newy;

        glBegin(GL_POLYGON); 
           for(theta = 0.0; theta &lt;= 360.0; theta += 1.0)
           {
               cx = r*cos(theta*(360.0/M_PI));
               cy = r*sin(theta*(360.0/M_PI));
               glVertex3f((newx = x - 360.0) +cx, (newy = y - 360.0) +cy, 0.0);
           }
        glEnd();
    

    }

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT); / clear the window /
    glMatrixMode(GL_MODELVIEW);

     double newx, newy;
     newx = x - 400.0;                   // x = 0.0 is at bottom left corner
     newy = y - 400.0;                   // y = 0.0 is at bottom left corner
     double vx1 = newx;                  // x vertex 1 of square
     double vy1 = newy;                  // y vertex 1 of square
     double vx2 = newx + 100.0;
     double vy2 = newy;
     double vx3 = newx;
     double vy3 = newy + 100.0;
     double vx4 = newx + 100.0;
     double vy4 = newy + 100.0;
    
     for( i = 0; i &lt;= 7; i++)
     {
        for(j = 0; j &lt;= 7; j++)
        {
           if( (i % 2) == 0 &amp;&amp; (j % 2) == 0)
              glColor3f(0.9, 0.5, 0.7);            // pink
           if( (i % 2) != 0 &amp;&amp; (j % 2) == 0)
              glColor3f(0.2, 0.5, 1.0);            // pastel blue
           if((i % 2) != 0 &amp;&amp; (j % 2) != 0)
              glColor3f(0.9, 0.5, 0.7);            // pink
           if ((i % 2) == 0 &amp;&amp; (j % 2) != 0)
              glColor3f(0.2, 0.5, 1.0);            // pastel blue
           glBegin(GL_POLYGON);
              glVertex2f(vx1, vy1);
              glVertex2f(vx2, vy2);
              glVertex2f(vx3, vy3);
              glVertex2f(vx4, vy4);
           glEnd();
           vx1+=100;
           vx2+=100;
           vx3+=100;
           vx4+=100;
        }
        vx1 = newx;
        vx2 = newx + 100.0;
        vx3 = newx;
        vx4 = newx + 100.0;
    
        vy1+=100;
        vy2+=100;
        vy3+=100;
        vy4+=100;
     }
     glFlush();                 /* send all commands */
    

    }

    void myMouse( int btn, int st, int mousex, int mousey)
    {
    / transform window x and y into world x and y /

       x = mousex - 40;
       y = -mousey + 760;
    
        if(btn == GLUT_LEFT_BUTTON &amp;&amp; st == GLUT_DOWN)
        {
            i = x / 100;
            j = y / 100;
    
                if(clicks % 2 != 0)
                   checkers[i][j] = 1;
                if(clicks % 2 == 0)
                   checkers[i][j] = 2;
    
               for(i = 0; i&lt;=7; i++)
               {
                   for(j = 0; j&lt;=7; j++)
                   {
                       if(checkers[i][j] == 1)
                       {
                          glColor3f(0.2, 0.5, 1.0);             //pastel blue
                          drawChecker(x, y, radius);
                       }
    
                       if(checkers[i][j] == 2)
                       {
                          glColor3f(0.9, 0.5, 0.7);             //pink
                          drawChecker(x, y, radius);
                       }
                   }
               }
            clicks++;
        }
    

    }

    void myReshape(GLsizei w, GLsizei h)
    {
    glViewport(0, 0, w, h);
    wheight = h; wwidth = w;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(-wwidth/2.0, wwidth/2.0, -wheight/2.0, wheight/2.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glutPostRedisplay();
    }

    int main(int argc, char argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowSize((int)(wwidth), (int)(wheight));
    glutCreateWindow("Program Three");
    myinit(); /
    set attributes
    /
    glutDisplayFunc(display); / display callback /
    glutReshapeFunc(myReshape); / reshape callback /
    glutMouseFunc(myMouse);
    glutMainLoop(); / enter event loop /
    return(0);
    }

    my second problem is that when the checkers are drawn, the colors are supposed to alternate with each click. I can get it to do this eight times, and then every time after that, they remain the same color each time I click on the "board". Can anyone help me with this?

    Thanks a lot.

     
  • Nobody/Anonymous

    This is really intended as a general purpose, getting started with Glut thread, please ask specific questions on their own thread.

    Thanks,

    Wayne

     
  • Nobody/Anonymous

    Hi,
    I'm using dev-c++ 4.9.9.2 on windows xp, and I'm just tring to get to grips with it, etc, get something working, but every time I compile it it tells me glutInit undeclared (first use of this function)...

    I followed the instructions in the getting started with open gl post, except i didnt put the library files into the lib folder as I dont think i had any...

    This is the package i downloaded:
    glut.3.7.6+.DevPak

    any help would be greatly appreciated,
    thanks
    newbSara

     
  • Wayne Keen

    Wayne Keen - 2006-03-30

    newbSara,

    I guess you did not read the post directly above yours before you posted.

    If you followed the directions in this thread, you did NOT get glut through the DevPack - this thread points you to a different site. That is the approach that has always worked for me.

    And you don't generally "download" a DevPack - you use the WebInstaller which gets the pack and installs it automagically.

    Please start a new thread with your question, and please, include your Basic 3. Always.

    In particular, the coompile log portion of the Basic 3 tells us what libraries you linked, and exactly what the nature of your errors are...

    Wayne

     
  • Nobody/Anonymous

    Hi!
    I use dev 4.9.9.2
    this is the compiler log:

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Dev-Cpp\main.cpp" -o "C:\Dev-Cpp\main.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lglut32 -lopengl32
    In file included from C:\Dev-Cpp\main.cpp:1:
    C:/Dev-Cpp/include/GL/glut.h:45: error: redeclaration of C++ built-in type `short'

    Execution terminated

    when I try to compile this file:

    include <GL/glut.h> //Einbindung der glut header Datei (bzw GL/glut.h);

    void Init(void) //Initsialisierungsfunktion

    {
    glClearColor(0.0,0.0,0.0,0.0); //Farbe wird auf schwarz gesetzt

    }

    void keyboard(unsigned char key, int x, int y) // Keyboardfunktion
    {
    switch(key){
    case 27: // Die Escape Taste hat den Wert 27
    exit(0); // wenn man ESC drückt verläßt er das Programm
    }
    }

    void display(void) // Darstellungsfunktion
    {
    glClear(GL_COLOR_BUFFER_BIT); // Hintergrundfarbe wird auf die mit glClearColor
    // festgelegt Farbe eingestellt
    glColor3f(0.5,0.5,0.5); // Farbe für Objekt wird auf grau eingestellt
    glBegin(GL_POLYGON); // Ab hier wird ein Objekt des Types Polygon erstellt
    glVertex2f(0.0,0.0); // x und y koordinate für den 1.Eckpunkt
    glVertex2f(-0.5,0.55); // 2. Eckpunkt
    glVertex2f(-0.15,-0.15);
    glEnd(); //Polygon wird hier beendet und erstellt

    glBegin(GL_POLYGON); // noch ein Polygon
    glVertex2f(0.0,0.0);
    glVertex2f(0.5,0.55);
    glVertex2f(0.15,-0.15);
    glEnd();

    glFlush(); // Objekte werden freigestellt und werden auf dem Bildschirm angezeigt
    }

    int main(int argc, char** argv) // Hauptfunktion
    {
    glutInit(&argc, argv); // Hauptinitsialisierung (keine Ahnung was da gemacht wird)
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); //Darstellungsmodus wird auf EinzelPuffer und RGB Farbmodus //gestellt
    glutInitWindowPosition(100,100); // Fensterposition
    glutInitWindowSize(500,500); // Fenstergröße
    glutCreateWindow("Polygon"); // Fenster wird erstellt und der Name erscheint in der Titelleiste
    Init(); //Funktion init wird gestartet
    glutDisplayFunc(display); // display funktion wird als Darstellungsfunktion erstellt
    glutKeyboardFunc(keyboard); //keyboard funktion wird aufgerufen bei einer Tastatureingabe
    glutMainLoop(); // Hauptschleife. Diese Funktion muss aufgerufen werden sonst funktioniert nichts

    return 0; // Rückgabewert für die main funktion da integer auf 0 also nichts
    }

    I put glut.h in the direcotry include/GL of dev c++

    Can somebody help me on that and explain it to me?!
    Thank you

     
  • Wayne Keen

    Wayne Keen - 2006-06-12

    "I put glut.h in the direcotry include/GL of dev c++"

    There is much more to do than that. A header is just a list of functions, it doesn't do anything.

    Please follow the directions given at the beginning of the thread. Get Glut where they tell you to, and put them where you are asked.

    After you have done that, and if you still have issues, please tell us, step by step, what you did - where you got things, where you put them. Please do NOT simply type something like "I followed the directions"

    Thanks.

    Wayne

     
  • Nobody/Anonymous

    Hi - I read the thread now very carefully and the only thing I recognized, that I have done differently is, that I didn't put -lglu32 to the linker command line - and now the programm I posted works. I'm sorry for asking bothering questions - I still don't understand what these words in The Linker Command Line do but for that I probaby have to find a german forum.

     
  • Wayne Keen

    Wayne Keen - 2006-06-12

    The lines in question "link" the Glut code to yours - enabling it to work.

    Wayne

     
  • Johnny

    Johnny - 2008-02-07

    I believe I am telling about well known but not solved problem:
    when compiling there are comes errors:
    [Linker error] undefined reference to `__glutInitWithExit@12' and etc.

    (1)My version of Dev-Cpp is 4.9.9.2

    (2)The code is:

    include <windows.h>

    include <gl/glut.h>

    include <stdlib.h>

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(1.0, 1.0,1.0);
    glBegin(GL_POLYGON);
    glVertex3f(0.25, 0.25, 0.0);
    glVertex3f(0.75, 0.25, 0.0);
    glVertex3f(0.75, 0.75, 0.0);
    glVertex3f(0.25, 0.75, 0.0);
    glEnd();

    glFlush();
    }

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

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);

    }

    int main(int argc, char** argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(250, 250);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("hello");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
    }

    (3) Full log is:
    Compiler: Default compiler
    Building Makefile: "E:\temp\opengl\Makefile.win"
    Executing make...
    make.exe -f "E:\temp\opengl\Makefile.win" all
    g++.exe main.o -o "opengl.exe" -L"lib" -lopengl32 -lglut32 -mwindows -lglut32 -lopengl32 -lglu32

    main.o(.text+0x1c):main.cpp: undefined reference to __glutInitWithExit@12' main.o(.text+0x3d):main.cpp: undefined reference toglutCreateWindowWithExit@8'
    main.o(.text+0x5d):main.cpp: undefined reference to `
    glutCreateMenuWithExit@8'
    collect2: ld returned 1 exit status

    make.exe: *** [opengl.exe] Error 1

    Execution terminated

     
<< < 1 2 3 (Page 3 of 3)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.