Easy3D 2.6.1
|
Accurate timing of GPU operations. More...
#include <easy3d/renderer/opengl_timer.h>
Public Member Functions | |
OpenGLTimer (bool start_timing=true) | |
Constructor. | |
virtual | ~OpenGLTimer () |
Destructor. | |
void | start () |
Start the timer. The next OpenGL call will be the first timed. | |
bool | is_running () const |
Check if the timer is running. | |
void | stop () |
Stop the timer. The previous OpenGL call will be the last timed. | |
double | time () |
Get the GPU time consumed since the last start. | |
Accurate timing of GPU operations.
Because the GPU is based on an asynchronously processed command stream that is implicitly generated by OpenGL calls, it is not possible to determine the amount of time spent processing a set of OpenGL calls by timing the calls themselves at the application level. Instead, the timing must be done via an asynchronous timer system. This timer is started and stopped at the beginning and end of the OpenGL commands of interest. However, the timing results must be queried at some point later, as the pipeline must complete before the timer values are known. This class implements such a timer that behaves like a CPU timer (See StopWatch).
Usage example:
|
explicit |
Constructor.
start_timing | Whether to start the timer immediately. |
|
inline |
Check if the timer is running.
true
if the timer is running, false
otherwise. void start | ( | ) |
Start the timer. The next OpenGL call will be the first timed.
void stop | ( | ) |
Stop the timer. The previous OpenGL call will be the last timed.
double time | ( | ) |
Get the GPU time consumed since the last start.