cgv
Loading...
Searching...
No Matches
gl_time_query.h
1#pragma once
2
3#include <cgv/render/texture.h>
4
5#include "lib_begin.h"
6
7namespace cgv {
8 namespace render {
9 namespace gl {
10
12class CGV_API gl_time_query
13{
14private:
15 context* ctx_ptr = nullptr;
16 unsigned int query = 0;
17
18public:
20 mutable std::string last_error;
21
26
28 bool init(context& ctx);
30 void destruct(context& ctx);
32 bool is_initialized() const;
33
35 void begin_scope() const;
37 void end_scope() const;
40 double collect() const;
41
44 inline double end_scope_and_collect() const {
45 end_scope();
46 return collect();
47 }
48
50 [[deprecated("Use begin_scope() instead, which does the exact same thing, but is named more clearly and fits better with the new way of using gl_time_query.")]]
51 void begin() const;
53 [[deprecated("This method blocks the calling thread until the scoped commands finish executing. Use end_scope() and collect() instead.")]]
54 double end() const;
55};
56
57 } // namespace cgv
58 } // namespace render
59} // namespace gl
60
61#include <cgv/config/lib_end.h>
base class for all drawables, which is independent of the used rendering API.
Definition context.h:670
double collect() const
collect the measured time, blocking until the query object is ready and the time can be retrieved ela...
double end_scope_and_collect() const
close the scope of OpenGL commands included in the time measurement and retrieve the duration immedia...
void end_scope() const
close the scope of OpenGL commands included in the time measurement
void destruct(context &ctx)
deinitialize the query
bool init(context &ctx)
initialize the time query by generating the query object, return success
void begin_scope() const
start scoping OpenGL commands for time measurement
bool is_initialized() const
check whether the time query has been initialized, i.e. the init method has been called successfully ...
gl_time_query()
construct an uninitialized time query
std::string last_error
a string that contains the last error, which is only set by the init method
namespace for opengl specific GPU programming
Definition gl.cxx:6
namespace for api independent GPU programming
this header is dependency free
Definition print.h:11