13 #ifndef OGLPLUS_QUERY_1107121519_HPP
14 #define OGLPLUS_QUERY_1107121519_HPP
30 #include <oglplus/enums/query_target.ipp>
33 #if !OGLPLUS_NO_ENUM_VALUE_NAMES
34 #include <oglplus/enums/query_target_names.ipp>
37 #if !OGLPLUS_ENUM_VALUE_RANGES
38 #include <oglplus/enums/query_target_range.ipp>
46 #include <oglplus/enums/conditional_render_mode.ipp>
49 #if !OGLPLUS_NO_ENUM_VALUE_NAMES
50 #include <oglplus/enums/conditional_render_mode_names.ipp>
53 #if !OGLPLUS_ENUM_VALUE_RANGES
54 #include <oglplus/enums/conditional_render_mode_range.ipp>
69 static void Gen(tag::Generate, GLsizei count, GLuint* names)
71 assert(names !=
nullptr);
72 OGLPLUS_GLFUNC(GenQueries)(count, names);
73 OGLPLUS_CHECK_SIMPLE(GenQueries);
75 #if GL_VERSION_4_5 || GL_ARB_direct_state_access
83 assert(names !=
nullptr);
84 OGLPLUS_GLFUNC(CreateQueries)(target, count, names);
85 OGLPLUS_CHECK_SIMPLE(CreateQueries);
90 void Gen(tag::Create create, GLsizei count, GLuint* names)
92 Gen(create, _type, count, names);
96 static void Delete(GLsizei count, GLuint* names)
98 assert(names !=
nullptr);
99 OGLPLUS_GLFUNC(DeleteQueries)(count, names);
100 OGLPLUS_VERIFY_SIMPLE(DeleteQueries);
103 static GLboolean IsA(GLuint name)
106 GLboolean result = OGLPLUS_GLFUNC(IsQuery)(name);
107 OGLPLUS_VERIFY_SIMPLE(IsQuery);
113 struct ObjectSubtype<tag::
Query>
118 class QueryActivator;
120 template <
typename ResultType>
128 :
public ObjZeroOps<tag::DirectState, tag::Query>
144 OGLPLUS_GLFUNC(BeginQuery)(GLenum(target), _name);
161 OGLPLUS_GLFUNC(EndQuery)(GLenum(target));
170 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
179 OGLPLUS_GLFUNC(BeginConditionalRender)(_name, GLenum(mode));
181 BeginConditionalRender,
195 OGLPLUS_GLFUNC(EndConditionalRender)();
196 OGLPLUS_VERIFY_SIMPLE(EndConditionalRender);
200 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_3 || GL_ARB_timer_query
209 OGLPLUS_GLFUNC(QueryCounter)(_name, GLenum(target));
239 GLuint result = GL_FALSE;
240 OGLPLUS_GLFUNC(GetQueryObjectuiv)(
242 GL_QUERY_RESULT_AVAILABLE,
250 return result == GL_TRUE;
253 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
263 OGLPLUS_GLFUNC(GetQueryObjectiv)(
274 #endif // GL_VERSION_3_0
285 OGLPLUS_GLFUNC(GetQueryObjectuiv)(
297 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_3 || GL_ARB_timer_query
308 OGLPLUS_GLFUNC(GetQueryObjecti64v)(
330 OGLPLUS_GLFUNC(GetQueryObjectui64v)(
341 #endif // timer query
344 template <
typename ResultType>
347 while(!ResultAvailable())
348 OGLPLUS_GLFUNC(Finish)();
362 template <
typename ResultType>
364 Execute(
Target target, ResultType& result);
398 : _query(std::move(temp._query))
399 , _target(temp._target)
400 , _alive(temp._alive)
425 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_3_0
448 : _alive(temp._alive)
482 template <
typename ResultType>
483 class QueryExecution :
public QueryActivator
492 ): QueryActivator(query, target)
496 QueryExecution(QueryExecution&& temp)
498 , _result(temp._result)
501 ~QueryExecution(
void)
503 try { WaitForResult(); }
507 void WaitForResult(
void)
511 Reference<QueryOps>(this->_query).WaitForResult(_result);
518 ObjectOps<tag::DirectState, tag::Query>::
519 Activate(Target target)
521 return QueryActivator(*
this, target);
524 template <
typename ResultType>
526 QueryExecution<ResultType>
541 #endif // include guard
void WaitForResult(ResultType &result) const
Waits for and queries the result.
Definition: query.hpp:345
QueryExecution< ResultType > Execute(Target target, ResultType &result)
Executes this query on the specified target and gets the result.
Definition: query.hpp:528
RAII conditional render activator/deactivator.
Definition: query.hpp:430
TIMESTAMP: Current timestamp query.
ConditionalRender(ConditionalRender &&temp)
ConditionalRenders are moveable.
Definition: query.hpp:447
void Counter(Target target)
Do a counter query on the specified target.
Definition: query.hpp:206
Reference to an existing Object.
QueryActivator Activator
The activator class.
Definition: query.hpp:353
ConditionalRenderMode
Conditional render modes.
Definition: query.hpp:45
QueryActivator(QueryName query, QueryTarget target)
Begins a query on the specified target.
Definition: query.hpp:385
Class wrapping query functions with (direct state access)
Definition: query.hpp:127
void Timestamp(void)
Do a timestamp query.
Definition: query.hpp:224
Declaration of OGLplus object-related error.
Generic OpenGL object wrapper.
Enumeration-related declarations.
ConditionalRender(QueryName query, ConditionalRenderMode mode)
Begins conditional render on query in the specified mode.
Definition: query.hpp:437
~ConditionalRender(void)
Ends the conditional render.
Definition: query.hpp:454
Implements operations applicable to named (non-zero) objects.
Definition: wrap_tpl.hpp:45
void Result(GLint64 &result) const
Get the query result.
Definition: query.hpp:305
QueryActivator(QueryActivator &&temp)
Activators are moveable.
Definition: query.hpp:397
void End(Target target)
End the query on the specified target.
Definition: query.hpp:158
void Begin(Target target)
Begin the query on the specified target.
Definition: query.hpp:141
RAII Query activator/deactivator.
Definition: query.hpp:375
Helper macro for optional checking of availability of GL function.
Implements operations applicable to any object including object 0 (zero)
Definition: fwd.hpp:157
Object< QueryOps > Query
An oglplus_object encapsulating the asynchronous query functionality.
Definition: query.hpp:537
void BeginConditionalRender(ConditionalRenderMode mode)
Begin conditional render on the query in the specified mode.
Definition: query.hpp:176
static void EndConditionalRender(void)
Ends currently active conditional render.
Definition: query.hpp:193
void Result(GLint &result) const
Get the query result.
Definition: query.hpp:260
A helper class automatically executing a query.
Definition: query.hpp:121
Exception class for GL object-related errors.
Definition: object.hpp:24
QueryTarget
Query bind target.
Definition: query.hpp:29
ObjectOps< tag::DirectState, tag::Query > QueryOps
Query operations with direct state access.
Definition: query.hpp:369
void Result(GLuint &result) const
Get the query result.
Definition: query.hpp:282
~QueryActivator(void)
Ends the query.
Definition: query.hpp:406
bool Finish(void)
Explicitly ends the query.
Definition: query.hpp:413
bool ResultAvailable(void) const
Returns true if the query result is available.
Definition: query.hpp:236
Allows to make managed copies of instances of Object.
Definition: fwd.hpp:172
bool Finish(void)
Explicitly ends the conditional render.
Definition: query.hpp:461
void Result(GLuint64 &result) const
Get the query result.
Definition: query.hpp:327
QueryTarget Target
Query execution target.
Definition: query.hpp:134