Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How can I do fast animation without dropping frames?

    General and Desktop
    1
    2
    2203
    Loading More Posts
    • 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
      Jonathan last edited by

      I have an application that generates a stream of mathematically created scenes. As soon as each scene is created I want to render it.

      As normal, the actual rendering is done in a subclass of QWidget by overriding the paintEvent() method.

      The scenes are created in a separate thread. As soon as a new scene is created I call update() on the QWidget subclass. I have to call update() rather than repaint() because the latter can't be called from a different thread. Unfortunately update() can be called multiple times before a scene is rendered, hence the reason I'm losing scenes or getting only partial updates.

      I've tried syncing the scene creation thread with the renderer by waiting in the scene creation thread until QWidget::paintingActive() returns false. However this makes no difference.

      Further investigation suggests that QWidget::paintEvent() can execute multiple times without the screen being updated.

      Any ideas will be most welcome!

      (I'm developing on a laptop running Windows 7)

      1 Reply Last reply Reply Quote 0
      • J
        Jonathan last edited by

        I think I've solved my own problem. I used a QMutex object to ensure that a new scene couldn't be created whilst the old scene was being rendered and vice versa.

        However I'm not sure why waiting on paintingActive() didn't have the same effect.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post