PrevUpHomeNext

Queries

#include <oglplus/query.hpp>

Common query operations

template <>
struct ObjectSubtype<tag::Query>
{
	typedef QueryTarget Type;
};

Operations with direct state access

template <>
class ObjectOps<tag::DirectState, tag::Query>
 : public ObjZeroOps<tag::DirectState, tag::Query>
{
public:
	typedef QueryTarget Target;

	void Begin(QueryTarget target); 1
	void End(QueryTarget target); 2

#if GL_VERSION_3_0
	void BeginConditionalRender(ConditionalRenderMode mode); 3
	static void EndConditionalRender(void); 4
#endif

#if GL_VERSION_3_3 || GL_ARB_timer_query
	void Counter(QueryTarget target); 5
	void Timestamp(void); 6
#endif

	Boolean ResultAvailable(void) const; 7

	void Result(GLint& result) const; 8
	void Result(GLuint& result) const;

#if GL_VERSION_3_3 || GL_ARB_timer_query
	void Result(GLint64& result) const;
	void Result(GLuint64& result) const;
#endif

	QueryActivator Activate(QueryTarget target); 9

	template <typename ResultType>
	QueryExecution<ResultType>
	Execute(QueryTarget target, ResultType& result); 10
};

typedef ObjectOps<tag::DirectState, tag::Query>
	QueryOps;

1

Begins a query on the specified target. See glBeginQuery.

2

Ends the currently active query on the specified target. See glEndQuery.

3

Begins conditional render on the query in the specified mode. See glBeginConditionalRender.

4

Ends currently active conditional render. See glEndConditionalRender.

5

Does a counter query on the specified target. See glQueryCounter.

6

Does a timestamp query. See glQueryCounter, GL_TIMESTAMP.

7

Returns true if the query result is available. See glGetQueryObject, GL_QUERY_RESULT_AVAILABLE.

8

Returns the query result. See glGetQueryObject, GL_QUERY_RESULT.

9

This function creates an instance of the QueryActivator class which begins a query on the specified target when it is constructed and ends this query when it is destroyed.

10

This function creates an instance of the QueryExecution class which begins a query on the specified target when it is constructed and ends this query and gets its result when it is destroyed.

Activator

class QueryActivator
{
public:
	QueryActivator(QueryActivator&&);

	QueryActivator(QueryName query, QueryTarget target); 1

	~QueryActivator(void) 2
	noexcept;

	bool Finish(void); 3
};

1

Begins a query on the specified target. See glBeginQuery.

2

Ends the currently active query. See glEndQuery.

3

Explicitly ends the query without waiting for the destructor. See glEndQuery.

Conditional render

#if GL_VERSION_3_0
class ConditionalRender
{
public:
	ConditionalRender(ConditionalRender&&);

	ConditionalRender(
		QueryName query,
		ConditionalRenderMode mode
	); 1

	~ConditionalRender(void) 2
	noexcept;

	bool Finish(void); 3
};
#endif

1

Begins conditional render on a query in the specified mode. See glBeginConditionalRender.

2

Ends the currently active conditional render. See glEndConditionalRender.

3

Explicitly ends the currently active conditional render. See glEndConditionalRender.

Execution

template <typename ResultType>
class QueryExecution
 : public QueryActivator
{
public:
	QueryExecution(QueryExecution&&);

	QueryExecution(
		QueryName query,
		QueryTarget target,
		ResultType& result
	); 1

	~QueryExecution(void) 2
	noexcept;

	void WaitForResult(void);  3
};

1

Begins a query on the specified target, taking a reference where the result will be stored . See glBeginQuery.

2

Ends the currently active query and waits for the result. See glEndQuery, glGetQueryObject, GL_QUERY_RESULT_AVAILABLE.

3

Explicitly ends the query and waits for the result. See glEndQuery.

Target

enum class QueryTarget : GLenum
{
	TimeElapsed                        = GL_TIME_ELAPSED,
	Timestamp                          = GL_TIMESTAMP,
	SamplesPassed                      = GL_SAMPLES_PASSED,
	AnySamplesPassed                   = GL_ANY_SAMPLES_PASSED,
	PrimitivesGenerated                = GL_PRIMITIVES_GENERATED,
	TransformFeedbackPrimitivesWritten = GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
	VerticesSubmitted                  = GL_VERTICES_SUBMITTED_ARB,
	PrimitivesSubmitted                = GL_PRIMITIVES_SUBMITTED_ARB,
	VertexShaderInvocations            = GL_VERTEX_SHADER_INVOCATIONS_ARB,
	TessControlShaderPatches           = GL_TESS_CONTROL_SHADER_PATCHES_ARB,
	TessEvaluationShaderInvocations    = GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB,
	GeometryShaderInvocations          = GL_GEOMETRY_SHADER_INVOCATIONS,
	GeometryShaderPrimitivesEmitted    = GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB,
	FragmentShaderInvocations          = GL_FRAGMENT_SHADER_INVOCATIONS_ARB,
	ComputeShaderInvocations           = GL_COMPUTE_SHADER_INVOCATIONS_ARB,
	ClippingInputPrimitives            = GL_CLIPPING_INPUT_PRIMITIVES_ARB,
	ClippingOutputPrimitives           = GL_CLIPPING_OUTPUT_PRIMITIVES_ARB,
	TransformFeedbackOverflow          = GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB,
	TransformFeedbackStreamOverflow    = GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB
};

template <>
Range<QueryTarget> EnumValueRange<QueryTarget>(void);

StrCRef EnumValueName(QueryTarget);

Conditional render mode

enum class ConditionalRenderMode : GLenum
{
	QueryWait                   = GL_QUERY_WAIT,
	QueryNoWait                 = GL_QUERY_NO_WAIT,
	QueryByRegionWait           = GL_QUERY_BY_REGION_WAIT,
	QueryByRegionNoWait         = GL_QUERY_BY_REGION_NO_WAIT,
	QueryWaitInverted           = GL_QUERY_WAIT_INVERTED,
	QueryNoWaitInverted         = GL_QUERY_NO_WAIT_INVERTED,
	QueryByRegionWaitInverted   = GL_QUERY_BY_REGION_WAIT_INVERTED,
	QueryByRegionNoWaitInverted = GL_QUERY_BY_REGION_NO_WAIT_INVERTED
};

template <>
Range<ConditionalRenderMode> EnumValueRange<ConditionalRenderMode>(void);

StrCRef EnumValueName(ConditionalRenderMode);

PrevUpHomeNext