I'm developing an application in Qt 4.7 which makes use of OpenGL. I know updateGL() must be c开发者_如何学Pythonalled in order to refresh the view, making a swap from the backbuffer but, how often should it be done?
It should be done as frequently as possible because i'm showing an animation (i.e. no static images). I know the biggest rate (fps) will be multiple of the monitor refresh. Let's suppose monitor vertical refresh if 50hz. updateGL() should be called at most every 20 ms. What happens if updateGL()'s takes more than 20 ms to complete? There would be any problem if i call updateGL() every, let's say, 1 ms? (i.e. overflowing a stack with queued updateGL() call events?The swap usually waits for vsync, so you can call it as often as you like, you won't be getting shearing or artifacts (in case you were worried).
W.r.t. Qt events, either use a QTimer set to fast (this silently discards events if they are not processed fast enough, i.e. no escalating event queue), or, you could post a redraw-event at the end of updateGL, essentially calling yourself.
The latter might not suit you, but it's an neat way of ensuring your paint loop runs as fast as possible, but not faster. ;)
精彩评论