Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change opengl app that creates two opengl windows to qt?
Forum Updated to NodeBB v4.3 + New Features

How to change opengl app that creates two opengl windows to qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
opengl
4 Posts 2 Posters 1.2k Views 1 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.
  • N Offline
    N Offline
    never_ever
    wrote on last edited by
    #1

    Hi,
    I try to use qt in my app and I found that there is opengl in Qt. I read lots of tutorials, but I am wondering one thing.
    In my app I have part of code responsible for creating two windows. In each window there is different view.

    void run()        
    {
        glutInit(&m_argc, m_argv);
        glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | GLUT_DOUBLE);
        glutInitWindowSize(m_width, m_height);
    
        m_arWindow = glutCreateWindow("AR");
        glutDisplayFunc(drawAr);
        glutSpecialFunc(keyCallback);
        glutPositionWindow(0, 0);
    
        m_vrWindow = glutCreateWindow("VR");
        glutDisplayFunc(drawVr);
        glutPositionWindow(0, m_height);
    
        glEnable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_COLOR_MATERIAL);
    
        glutMouseFunc(mouse);
        glutMotionFunc(motion);
        glutMainLoop();
    }
    

    If I want to subclass QGLWidget, I have to do this for each window (create one class based on QGLWidget for each window)? Or I should create only one class and in paintGL() method I should use both function?

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

      Hi,

      Since you have two windows, you are likely showing something different on each, right ? If so then build two widgets. By the way, if you are using Qt 5, you should start directly with QOpenGLWidget.

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

      N 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Since you have two windows, you are likely showing something different on each, right ? If so then build two widgets. By the way, if you are using Qt 5, you should start directly with QOpenGLWidget.

        N Offline
        N Offline
        never_ever
        wrote on last edited by never_ever
        #3

        @SGaist So, I have to subclass QOpenGLWidget twice. Once for class creating one window, second for class creating second window? What if in my version I had above function in other thread (it was necessary in my app)? If I have to subclass also QThread in that classes and create two additional threads for them?

        If I use QOpenGlWidget is there any corresponding function to glutSwapBuffers? In QGlWidget I see swapBuffers(), but in QOpenGLWidget I don't.

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

          Take a look at the examples in Qt's documentation, there's one showing how to use thread and QOpenGLWidget

          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