OpenGL frame timer with Qt

To compare impacts of different optimizations in terms of rendering duration, it can be useful to implement a frame timer.  A frame timer counts the amount of time that elapsed during a paint() call. Since version 3.3 OpenGL provides the  GL_TIME_ELAPSED  query which returns the time between to calls in nanoseconds. The code below shows a very basic example in plain C/OpenGL.

Since the availability of those queries depends on the underlying platform, hardware and OpenGL version, Qt provides QOpenGLTimerQuery as a wrapper class for that functionality. The same code for the use within a QGLWidget can be seen in the following snippet.


This post is part of a series documenting the progress of the development of a OpenGL/Qt/C++ based application for my fast realistic rendering course at the Universitat Politècnica de Catalunya. The complete source code can be found on github.


QOpenGLTimerQuery Class | QtGui 5.1 | Documentation | Qt Project. (n.d.). Retrieved March 24, 2014, from
OpenGL Timer Query. (n.d.). Retrieved March 24, 2014, from

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.