Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. qt creator not work with freeglut ??

qt creator not work with freeglut ??

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
4 Posts 2 Posters 724 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • timob256T Offline
    timob256T Offline
    timob256
    wrote on last edited by
    #1

    Now I tried to connect free glut, but for some reason again the opportunity, nothing comes out :(

    unitled22.pro

    TEMPLATE = app
    CONFIG += console c++11
    CONFIG -= app_bundle
    CONFIG -= qt
    
    SOURCES += \
            main.cpp
    
    win32: LIBS += -L$$PWD/freeglut/lib/x64/ -lfreeglut
    
    INCLUDEPATH += $$PWD/freeglut/lib/x64
    DEPENDPATH += $$PWD/freeglut/lib/x64
    
    win32: LIBS += -L$$PWD/glew-2.1.0/lib/Release/x64/ -lglew32
    
    INCLUDEPATH += $$PWD/glew-2.1.0/include/GL
    DEPENDPATH += $$PWD/glew-2.1.0/include/GL
    
    INCLUDEPATH += $$PWD/freeglut/include/GL/ \  
                    $$PWD/glew-2.1.0/include/GL/
    

    main.cpp

    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    
    
    #include <freeglut.h>
    #include <glew.h>
    
    
    #define PI 3.14159265358979324
    
    using namespace std;
    
    // Globals.
    static float R = 40.0; // Radius of circle.
    static float X = 50.0; // X-coordinate of center of circle.
    static float Y = 50.0; // Y-coordinate of center of circle.
    static int numVertices = 5; // Number of vertices on circle.
    
    // Drawing routine.
    void drawScene(void)
    {
       float t = 0; // Angle parameter.
       int i;
    
       glClear(GL_COLOR_BUFFER_BIT);
    
       glColor3f(0.0, 0.0, 0.0);
    
       // Draw a line loop with vertices at equal angles apart on a circle
       // with center at (X, Y) and radius R, The vertices are colored randomly.
       glBegin(GL_LINE_LOOP);
          for(i = 0; i < numVertices; ++i)
          {
             glColor3f((float)rand()/(float)RAND_MAX, (float)rand()/(float)RAND_MAX, (float)rand()/(float)RAND_MAX);
             glVertex3f(X + R * cos(t), Y + R * sin(t), 0.0);
             t += 2 * PI / numVertices;
          }
       glEnd();
    
       glFlush();
    }
    
    // Initialization routine.
    void setup(void)
    {
       glClearColor(1.0, 1.0, 1.0, 0.0);
    }
    
    // OpenGL window reshape routine.
    void resize(int w, int h)
    {
       glViewport(0, 0, w, h);
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
       glMatrixMode(GL_MODELVIEW);
       glLoadIdentity();
    }
    
    // Keyboard input processing routine.
    void keyInput(unsigned char key, int x, int y)
    {
       switch(key)
       {
          case 27:
             exit(0);
             break;
          case '+':
             numVertices++;
             glutPostRedisplay();
             break;
          case '-':
             if (numVertices > 3) numVertices--;
             glutPostRedisplay();
             break;
          default:
             break;
       }
    }
    
    // Routine to output interaction instructions to the C++ window.
    void printInteraction(void)
    {
       cout << "Interaction:" << endl;
       cout << "Press +/- to increase/decrease the number of vertices on the circle." << endl;
    }
    
    // Main routine.
    int main(int argc, char **argv)
    {
       printInteraction();
       glutInit(&argc, argv);
    
       glutInitContextVersion(4, 3);
       glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE);
    
       glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
       glutInitWindowSize(500, 500);
       glutInitWindowPosition(100, 100);
       glutCreateWindow("circle.cpp");
       glutDisplayFunc(drawScene);
       glutReshapeFunc(resize);
       glutKeyboardFunc(keyInput);
    
       glewExperimental = GL_TRUE;
       glewInit();
    
       setup();
    
       glutMainLoop();
    }
    

    I get this result :(

    c80498b5-0286-4389-ac3e-8879386c6401-изображение.png

    db623a51-662d-4a6d-84e8-3f881c4d0394-изображение.png

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Aren't you missing the standard OpenGL "gl.h" include ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • timob256T Offline
        timob256T Offline
        timob256
        wrote on last edited by
        #3

        @SGaist said in qt creator not work with freeglut ??:

        Aren't you missing the standard OpenGL "gl.h" include ?

        this damp windows linux this work

        unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lOpenGL
        
        INCLUDEPATH += $$PWD/../../../../usr/include/GL
        DEPENDPATH += $$PWD/../../../../usr/include/GL
        
        unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lGLEW
        
        INCLUDEPATH += $$PWD/../../../../usr/include/GL
        DEPENDPATH += $$PWD/../../../../usr/include/GL
        
        unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lglut
        
        INCLUDEPATH += $$PWD/../../../../usr/include/GL
        DEPENDPATH += $$PWD/../../../../usr/include/GL
        
        unix:!macx: LIBS += -L$$PWD/../../../../usr/lib/x86_64-linux-gnu/ -lGLU
        
        INCLUDEPATH += $$PWD/../../../../usr/include/GL
        DEPENDPATH += $$PWD/../../../../usr/include/GL
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @timob256 said in qt creator not work with freeglut ??:

          this damp windows linux this work

          What do you mean ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved