gcc main.c -lGL -lGLU -lglut



  • hi:
    I have a file (main.c) .
    I use gcc main.c -lGL -lGLU -lglut (is ok).
    How can i build in qtcreate 4.2.0(qt 5.7.1) ? Thank you!

    #include <GL/glut.h>

    void myinit();
    void display();

    int main(int argc, char **argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(0,0);
    glutCreateWindow("simple OpenGL example");
    glutDisplayFunc(display);
    myinit();
    glutMainLoop();
    }

    void myinit()
    {
    glClearColor(0.0,0.0,0.0,1.0);
    glColor3f(0.0,1.0,0.0);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0, 50.0, 0.0, 50.0);
    glMatrixMode(GL_MODELVIEW);
    

    }

    void display()
    {
    GLfloat vertices[3][2] = {{0.0,0.0},{25.0,50.0},{50.0,0.0}};
    int j,k;
    int rand();
    GLfloat p[2] = {7.5, 5.0};
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POINTS);
    for(k=0;k<900000;k++)
    {
    j=rand()%3;
    p[0] = (p[0]+vertices[j][0]) / 2.0;
    p[1] = (p[1]+vertices[j][1]) / 2.0;
    glVertex2fv(p);
    }

    glEnd();
    glFlush();
    

    }


  • Lifetime Qt Champion

    Hi,

    Do you mean having a .pro file with:

    SOURCES += main.c
    LIBS += -lGL -lGLU -lglut
    

    in it ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.