Results 1 to 20 of 20

Thread: Fast Timer Updates vs. Monitor Refresh Rates

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    It may sound as a dumb question but why do you want to update the widget every 6ms? This gives about 167 frames per second, I can hardly think of a reason why anyone would want so many ui updates per second. Especially with a 60Hz display. I can't even think of a hardware that would be capable of doing as many updates and still be able to provide some data to update the ui with.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Dec 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    Quote Originally Posted by wysota View Post
    It may sound as a dumb question but why do you want to update the widget every 6ms? This gives about 167 frames per second, I can hardly think of a reason why anyone would want so many ui updates per second. Especially with a 60Hz display. I can't even think of a hardware that would be capable of doing as many updates and still be able to provide some data to update the ui with.
    Haha, silly typo, my bad-
    I meant 16ms, or more precisely, 16.666...ms.
    I need 60Hz, meaning refresh every time the screen refreshes.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    Ok, so how exactly do you force your widget to redraw?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Dec 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    I'm using a QTimer...is there another way, maybe blocking until a vertical sync event? I've tried using swapBuffers but I can't get it to work without a timer.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    Quote Originally Posted by artoonie View Post
    I'm using a QTimer...
    Show us the code.
    Last edited by wysota; 7th December 2010 at 11:24.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Dec 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    Quote Originally Posted by wysota View Post
    Quote Originally Posted by artoonie View Post
    I'm using a QTimer...QUOTE]
    Show us the code.
    It's been established that timers are not the way to go, but I'll paste what I have:
    Qt Code:
    1. Flickerer::Flickerer(int timerInterval, QWidget *parent) {
    2. m_timer = new QTimer( this );
    3. connect( m_timer, SIGNAL(timeout()), this, SLOT(timeOutSlot()) );
    4. m_timer->start( timerInterval );
    5. }
    6. void Flickerer::timeOutSlot()
    7. {
    8. showingG1 = !showingG1;
    9. updateGL();
    10. }
    11. void Flickerer::paintGL()
    12. {
    13. if(showingG1) /* paints gradient 1 */ else /* paints gradient 2 */
    14. }
    To copy to clipboard, switch view to plain text mode 




    QTimer can be set in whole milliseconds only. Approximating a 1/60 seconds rate with 16 msecs will lead a whole frame difference in time after 24 or 25 frames even if the timer events were perfectly spaced. A 17 msec approximation will extend the sync out to around 48-50 frames. QTimer events are processed when the program returns to the event loop after the time has expired. Depending on what else the program is doing, like rendering your gradient, this might be a significant delay. The combination of the two will lead to a mismatch that is variable with activity.

    MythTV can use timers to maintain video refresh sync, but I believe it also has extensive frame counting over relatively long periods to determine the average frame rate and drops/duplicates frames to realign things periodically. The preferred method in MythTV is to use the OpenGL vsync. I don't know how this can be accessed.
    I agree- I need to use OpenGL vsync but I don't know how to get a signal from the display so I'd know when to update.



    Thanks you.

  7. #7
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Fast Timer Updates vs. Monitor Refresh Rates

    You do not need to get the signal from the display. OpenGl has a function that does that for you.

    What I would try to do:
    Create a graphicsview that contains the user interface. Make it so that everything inside the graphicsview is painted via OpenGl
    There are lots of tutorials in the Qt labs and documentation.
    And then use the information from the blog post about blocking the eventloop and synchronising the eventloop to the refresh rate of the monitor.

    If you use a graphicsview and opengl, the effects possible with your user interface are infinite, although limited to the contents of the graphicsview.

    Edit:
    Here's a nice example:
    http://labs.qt.nokia.com/2008/06/27/...s-with-opengl/

    Edit 2:
    You need this function:
    http://doc.qt.nokia.com/latest/qglfo...etSwapInterval
    Set it to 1

    Tip:
    QML does this out of the box. It's worth studying the code.
    Last edited by tbscope; 7th December 2010 at 04:34.

Similar Threads

  1. X Monitor in a Qt form
    By prasenjit in forum Qt-based Software
    Replies: 1
    Last Post: 29th April 2010, 06:58
  2. Monitor a new added File
    By designer.software in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2010, 09:50
  3. Replies: 2
    Last Post: 10th August 2009, 09:45
  4. Qt system monitor?
    By khopper in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 15:32
  5. How to calculate Monitor Resolution?
    By ashukla in forum Qt Programming
    Replies: 2
    Last Post: 7th October 2007, 07:28

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.