Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Question about migrating OpenGL from QGLWidget to QWindow
Forum Updated to NodeBB v4.3 + New Features

Question about migrating OpenGL from QGLWidget to QWindow

Scheduled Pinned Locked Moved Game Development
4 Posts 2 Posters 2.6k 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.
  • J Offline
    J Offline
    john_god
    wrote on last edited by
    #1

    I'm migrating a project from Qt4 with OpenGL in QGLWidget to Qt5 with OpenGL in QWindow.

    This "project":https://github.com/advancingu/Qt5OpenGL from Sean Harmer "Dev Days Talk":http://www.youtube.com/watch?v=GYa5DLV6ADQ has help me with with some doubts, but one thing is not clear, why nothing is draw if I disable the QTimer in Window.ccp constructor ? I'm guessing it's because paintGL() is a virtual function that works under the wood in QGLWidget, while in QWindow the equivalent is just a user defined function. Also I've notice that in QWindow, if I call paintGl() from the resizeGl() function, everything works, the triangle is draw without the timer (wich seems a waste of resources if we don't need animations). Can someone please clarify ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Skyrpex
      wrote on last edited by
      #2

      The timer's job in Window.cpp is to call updateScene() at a rate of 16 times per second, so disabling it the scene is never drawn.

      If you put paintGl() inside resizeGl(), the window will be drawn only when the window is resized, and also the scene won't get updated (so it won't change).

      it's up to you what should happen to update and draw the scene.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        john_god
        wrote on last edited by
        #3

        QTimer is responsible for updating the scene, but I have nothing to update, so I'm disabling the timer. I just wanna draw what's inside the painGL(), that is the triangle, and it doenst get draw, unless I call paintGL() from resizeGL() . This behavior is different from QGLwidget, where I can draw anything from paintGL, without timers, and without having to call paintGL() from resizeGL(). This is what's puzzling me.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Skyrpex
          wrote on last edited by
          #4

          That's because paintGL() is a virtual function of QGLWidget, which is called by itself in certain situations (I guess).

          QWindow doesn't have that virtual function, so it's up to you to call paintGL(). Maybe you should do inside showEvent().

          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