QT and Visual Studio Crashing when using GLUT objects?



  • Hi Guys,

    I am working in a task to create a program in OpenGL in Visual Studio with QT framework.

    I wanted to learn the first steps in this direction, so I wanted to create a TeaPot just for testing:

    #include "glwidget.h"
    #include <GL/glut.h>
    GLWidget::GLWidget(QWidget *parent)
        : QGLWidget(parent)
    {
    }
    
    void GLWidget::initiliazeGL(){
        glClearColor(1, 1, 0, 1);
    }
    void GLWidget::paintGL(){
       glClear(GL_COLOR_BUFFER_BIT);
    
        glutWireTeapot(1.0);
    }
    void GLWidget::resizeGL(int w, int h){
    
    }
    

    Above is the class where I put my code. First I have tried to create a Rectangle with GL_TRIANGLES, and it worked, but when I try to add "glutWireTeapot", or "glutSolidTeapot", or "glutSolidCube" etc... it crashes the application.

    In QT Creator it says:
    The program has unexpectedly finished.
    C:~//~//~//~~~\debug\testBug2.exe crashed[

    In Visual Studio 2013 it says:

    Unhandled exception at 0x000007FEE7C95AAF (freeglut.dll) in testBug2.exe: 0xC0000005: Access violation reading location 0x0000000000000034.

    When I saw the message in Visual Studio about the freeglut.dll, I went and deleted the freeglut files, downloaded freeglut again and added the files to the destination folders. But still, it didn't work :(

    Does anybody have any idea what the problem is?


  • Qt Champions 2016

    hi
    @taulant01 said:
    freeglut

    In old days one has to call glutInit before using any of the functions.

    Never tried freeglut so dont know if you still must

    but it does seem so
    http://freeglut.sourceforge.net/docs/api.php#Initialization


  • Moderators

    As @mrjj said you need to initialize freeglut first. But thre's really no point in using freeglut with Qt at all. You already have a window (GLWidget), maouse and keyboard handling and access to OpenGL functions (QOpenGLFunctions). In this setup freeglut is kinda redundant and can only create problems (clashing gl names etc.). I'd say just stick with Qt if you already started with it.



  • @taulant01 said:

    glutSolidTeapot

    Qt doen't replace glutWireTeapot etc.


  • Moderators

    Qt doen't replace glutWireTeapot etc.

    Yes, but except for a one-time example what's the use of it these days? One should use shaders and VBOs anyway.



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