Magnum::GL::PrimitiveQuery class

Query for primitives.

Queries count of generated primitives from vertex shader, geometry shader or transform feedback. Example usage:

GL::PrimitiveQuery q{GL::PrimitiveQuery::Target::PrimitivesGenerated};

q.begin();
// rendering...
q.end();

if(!q.resultAvailable()) {
    // do some work until to give OpenGL some time...
}

// ...or block until the result is available
UnsignedInt primitiveCount = q.result<UnsignedInt>();

Base classes

class AbstractQuery
Base class for queries.

Public types

enum class Target: GLenum { PrimitivesGenerated = GL_PRIMITIVES_GENERATED, TransformFeedbackPrimitivesWritten = GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, TransformFeedbackOverflow = GL_TRANSFORM_FEEDBACK_OVERFLOW, TransformFeedbackStreamOverflow = GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW }
Query target.

Public static functions

static auto wrap(GLuint id, Target target, ObjectFlags flags = {}) -> PrimitiveQuery
Wrap existing OpenGL primitive query object.

Constructors, destructors, conversion operators

PrimitiveQuery(Target target) explicit
Constructor.
PrimitiveQuery(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
PrimitiveQuery(const PrimitiveQuery&) deleted
Copying is not allowed.
PrimitiveQuery(PrimitiveQuery&&) defaulted noexcept
Move constructor.

Public functions

auto operator=(const PrimitiveQuery&) -> PrimitiveQuery& deleted
Copying is not allowed.
auto operator=(PrimitiveQuery&&) -> PrimitiveQuery& defaulted noexcept
Move assignment.
void begin()
Begin query.
void begin(UnsignedInt index)
Begin indexed query.
void end()
End query.

Enum documentation

enum class Magnum::GL::PrimitiveQuery::Target: GLenum

Query target.

Enumerators
PrimitivesGenerated

Count of primitives generated from vertex shader or geometry shader. When used with begin(UnsignedInt), the index must be lower than TransformFeedback::maxVertexStreams(). Use result<UnsignedInt>() or result<Int>() to retrieve the result.

TransformFeedbackPrimitivesWritten

Count of primitives written to transform feedback buffer. When used with begin(UnsignedInt), the index must be lower than TransformFeedback::maxVertexStreams(). Use result<UnsignedInt>() or result<Int>() to retrieve the result.

TransformFeedbackOverflow

Transform feedback overflow. When used with begin(UnsignedInt), the index must be 0. Use result<bool>() to retrieve the result.

TransformFeedbackStreamOverflow

Transform feedback stream overflow. When used with begin(UnsignedInt), the index must be lower than TransformFeedback::maxVertexStreams(). Use result<bool>() to retrieve the result.

Function documentation

static PrimitiveQuery Magnum::GL::PrimitiveQuery::wrap(GLuint id, Target target, ObjectFlags flags = {})

Wrap existing OpenGL primitive query object.

Parameters
id OpenGL primitive query ID
target Query target
flags Object creation flags

The id is expected to be of an existing OpenGL query object. Unlike query created using constructor, the OpenGL object is by default not deleted on destruction, use flags for different behavior.

Magnum::GL::PrimitiveQuery::PrimitiveQuery(Target target) explicit

Constructor.

Creates new OpenGL query object. If ARB_direct_state_access (part of OpenGL 4.5) is not available, the query is created on first use.

Magnum::GL::PrimitiveQuery::PrimitiveQuery(NoCreateT) explicit noexcept

Construct without creating the underlying OpenGL object.

The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.

This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active. However note that this is a low-level and a potentially dangerous API, see the documentation of NoCreate for alternatives.

void Magnum::GL::PrimitiveQuery::begin()

Begin query.

Begins counting until end() is called. Equivalent to calling begin(UnsignedInt) with index set to 0.

void Magnum::GL::PrimitiveQuery::begin(UnsignedInt index)

Begin indexed query.

Begins counting until end() is called.

void Magnum::GL::PrimitiveQuery::end()

End query.

Ends the non-indexed or indexed query started with begin() or begin(UnsignedInt). The result can be then retrieved by calling result().