Create a Core Profile OpenGL app

  • Hi,

    I want to create an OpenGL app with Qt but my code segfault (11) on mac. My code is very short. The same code works with OpenGL 2.1.

    #include <GL/glew.h>                                   
    #include <iostream>                                    
    #include <QApplication>                                
    #include <QOpenGLWidget>                               
    int main(int argc, char** argv){          
            QApplication app(argc, argv);                  
            QSurfaceFormat format;                         
            QOpenGLWidget opengl;                          
            opengl.setGeometry(30, 30, 600, 600);          
            return app.exec();                             

    [EDIT]: I just test on Windows and it's works. What is the problem with mac ?

    Best regards,

  • Ok I found the solution. I suppose mac use only the default opengl surface.
    I juste change my code like that: QSurfaceFormat::setDefaultFormat( format );

    Tell me why if you know :)

  • Hi,
    OSX only supports OpenGL 4.1. Core Profile and Compatibility mode (means only 4.1. Specification works). Compatibility Mode is only supported until OpenGL 2.1. So for me it works this way:

    #ifdef APPLE
    format.setVersion(4, 1);
    format.setVersion(4, 5);

Log in to reply

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