Graphics Reference
In-Depth Information
as optimization to avoid performing geometry processing on obscured
objects whose bounding volume is obscured.
Occlusion queries can be started and ended using
glBeginQuery
and
glEndQuery
, respectively, with
GL_ANY_SAMPLES_PASSED
or
GL_ANY_SAMPLES_PASSED_CONSERVATIVE
target.
void
glBeginQuery
(GLenum
target,
GLuint
id
)
void
glEndQuery
(GLenum
target
)
target
specifies the target type of query object; valid values are
GL_ANY_SAMPLES_PASSED
GL_ANY_SAMPLES_PASSED_CONSERVATIVE
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
id
specifies the name of the query object (
glBeginQuery
only)
Using the
GL_ANY_SAMPLES_PASSED
target will return the
precise boolean state indicating whether any samples passed the
depth test. The
GL_ANY_SAMPLES_PASSED_CONSERVATIVE
target
can offer better performance but a less precise answer. Using
GL_ANY_SAMPLES_PASSED_CONSERVATIVE
, some implementations may
return
GL_TRUE
even if no sample passed the depth test.
The
id
is created using
glGenQueries
and deleted using
glDeleteQueries
.
void
glGenQueries
(GLsizei
n,
GLuint *
ids
)
n
specifies the number of query name objects to be generated
ids
specifies an array to store the list of query name objects
void
glDeleteQueries
(GLsizei
n,
const GLuint *
ids
)
n
specifies the number of query name objects to be deleted
ids
specifies an array of the list of query name objects to be deleted
After you have specified the boundary of the query object using
glBeginQuery
and
glEndQuery
, you can use
glGetQueryObjectuiv
to
retrieve the result of the query object.