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 double buffer with Qt and WGLWidget
Forum Updated to NodeBB v4.3 + New Features

how to double buffer with Qt and WGLWidget

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 3.2k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    What version of Qt are you using ?
    On what platform ?

    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
    1
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #3

      Get rid of the update() calls in your paint methods. They are redundant. Also read the section about threading in QOpenGLWidget.

      B 1 Reply Last reply
      2
      • Kent-DorfmanK Kent-Dorfman

        Get rid of the update() calls in your paint methods. They are redundant. Also read the section about threading in QOpenGLWidget.

        B Offline
        B Offline
        BKBK
        wrote on last edited by BKBK
        #4

        @Kent-Dorfman
        We are using Centos Linux, version 7.
        Unfortunately, (very) we are using Qt3. That is something I cannot overcome. A number of people have done Qt work here but most have moved on and I am the first to use OpenGL within Qt in a Linux environment. This is my first exposure to both of them.
        I removed update() from everywhere but paintGL(). Deleting it from there stops all the QGLWidget updates while everything else seems to be fine.

        Is there something I could look at to see how often Qt is doing a update/paint/draw? Just maybe that would provide a clue.

        1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by Kent-Dorfman
          #5

          if it is Qt3 then I cannot be much more help. Probably would have been a good idea to mention that in the initial post. Good luck!

          As a test you might port your code to Qt5 just to test whether the problem is version specific. It is also sometimes beneficial to be able to show when you run up against a wall in legacy software and can justify that it won't get fixed without an update to a supported platform.

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

            Ouch... Then you should start by running the Qt OpenGL examples to see if they are running properly. This should rule out graphic stack related problem.

            It should also give you some hints about how to implement custom QGLWidget based application.

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

            B 1 Reply Last reply
            1
            • SGaistS SGaist

              Ouch... Then you should start by running the Qt OpenGL examples to see if they are running properly. This should rule out graphic stack related problem.

              It should also give you some hints about how to implement custom QGLWidget based application.

              B Offline
              B Offline
              BKBK
              wrote on last edited by
              #7

              @SGaist I did implement the example GL application in the book “C++ GUI Programming with QT3” It worked rather well, was very smooth. As I look at the strip chart app and from a post on the Khronos forum, it occurs to me that maybe it is really double buffering. The screen appears to alternate between a blank screen and my drawn data. I don't know how to access the "other" buffer.
              Yes I understand about Qt3 being really old. I appreciate your replies just the same. Thank you.

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

                First thing I would do is not call update from paintGL. You shouldn't need that.

                Can you start from one of the working example and there implement just your drawing in there ?

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

                B 1 Reply Last reply
                0
                • SGaistS SGaist

                  First thing I would do is not call update from paintGL. You shouldn't need that.

                  Can you start from one of the working example and there implement just your drawing in there ?

                  B Offline
                  B Offline
                  BKBK
                  wrote on last edited by
                  #9

                  @SGaist When paintGL() does not have update(), nothing will paint. paintGL() gets called one time on startup and never again. Still, following your concept I worry that there is something I am missing in this whole concept. I will continue thinking on it and trying new things as I think of them.
                  I don't know if I can put the GL widget from the strip chart into the demo app. I will look at that possibility.

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

                    My suggestion is to rather change the rendering code of the example step by step to become your chart rendering.

                    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
                    • B Offline
                      B Offline
                      BKBK
                      wrote on last edited by
                      #11

                      I have apparently solved the flicker problem. update() was removed from everywhere except paintGL(). That one does need to be tickled on a regular basis. Once done, paintGL() runs at 60 Hz. I do not completely understand how this works. Maybe as I continue working this the light will brighten.

                      I created an update_glortho() which makes a system call to get the current clock time and calls GLortho(), the openGL function that sets all the clipping. That controls the vertical scaling and moving the chart according to time. Using that means the app does not do any explicit scaling. The replies from SGaist were instrumental in getting my focus in the right place. And it does appear that Qt is handling the double buffering behind the scenes.
                      Now I know a bit more about graphics and quite a bit more about how versatile Qt and OpenGL are.

                      Thank you for your time and patience.

                      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