Easy3D 2.5.3
opengl_timer.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_RENDERER_OPENGL_TIMER_H
28#define EASY3D_RENDERER_OPENGL_TIMER_H
29
30namespace easy3d {
31
54 {
55 public:
56 // start the new timer by default.
57 explicit OpenGLTimer(bool start_timing = true);
58 virtual ~OpenGLTimer();
59
60 // Start the timer. The next OpenGL call will be the first timed.
61 // This must be called from a thread with the OpenGL context bound.
62 void start();
63
64 // Is the timer running.
65 bool is_running() const { return running_; }
66
67 // Stop the timer (the previous OpenGL call will be the last timed).
68 // This must be called from a thread with the OpenGL context bound.
69 void stop();
70
71 // return the GPU time consumed since last start (in milliseconds).
72 double time();
73
74 protected:
75 unsigned int query_id_;
76 bool running_;
77 };
78
79}
80
81
82#endif // EASY3D_RENDERER_OPENGL_TIMER_H
Accurate timing of GPU operations.
Definition: opengl_timer.h:54
Definition: collider.cpp:182