How properly initialize QOpenGLWidget when moving project from opengl to Qt?



  • Hi,
    I have program where I initialize OpenGL:

    void initFunc()
    {
        glutInit(&m_argc, m_argv);     //(1)
        glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE);    // (2)
        glutInitWindowSize(m_width, m_height);      //(3)
       //and so on...
    }
    

    I know that first(1) and third(3) line I can omit. I use Qt for this. But what with second line (2). If there is some corresponding function to that or I should also skip it.

    I know that I can enable for example depth_test by using glEnable(GL_DEPTH_TEST); But if it will be enough? What with other properties like rgb or double?


  • Lifetime Qt Champion

    Hi,

    QSufaceFormat is what you are looking for



  • So I can change second line to:

    QSurfaceFormat format;
    format.setDepthBufferSize(16);
    format.setBlueBufferSize(0);
    format.setGreenBufferSize(0);
    format.setRedBufferSize(0);
    this->setFormat(format);
    

    And if I think right, GLUT_DOUBLE I can change to setStereo(true).
    If I have to set all this options or it is default in Qt?


  • Lifetime Qt Champion

    No, setStereo is for stereoscopic view i.e. 3D image one for the left and one for the right eye.

    For double buffering, use setSwapBehavior



  • Oh, thanks, I search for that


Log in to reply
 

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