OcclusionQueryclass represents an occlusion query operation.
class OcclusionQuery : public ListElement<OcclusionQuery>
||Returns the cookie stored in an occlusion query object.|
||Sets the render callback function for an occlusion query object.|
||Returns the area that was unoccluded during an occlusion query.|
OcclusionQuery(RenderCallback *callback, void *cookie);
||A pointer to the occlusion query's render callback function.|
||The cookie that is passed to the render callback function as its last parameter.|
OcclusionQueryclass represents an occlusion query operation that can be attached to a renderable object. When such a renderable object is rendered as an effect, the GPU counts how many fragments pass the depth test. This information is reported through a render callback function later so that it can be used to alter the appearance of some other renderable object. The render callback function is specified by the
callbackparameter, which must point to a function having the following signature defined by the
typedef void RenderCallback(OcclusionQuery *, List<Renderable> *, void *);
cookieparameter specifies a user-defined pointer that is passed to the render callback function as its last parameter.
An occlusion query is attached to a
Renderableobject by calling the
Renderable::SetOcclusionQueryfunction before the renderable object is first rendered. The renderable object is typically created with the render flags
kRenderDepthInhibitall set so that the depth test is performed, but nothing is written to the color buffer or depth buffer.
When the render callback function is called, the first parameter is a pointer to the occlusion query object, and the second parameter points to a list of renderable objects. The render callback function should call the
OcclusionQuery::GetUnoccludedAreafunction to determine the normalized viewport area that passed the depth test when the occlusion query was rendered and optionally add items to the list of renderable objects after making adjustments to their appearance as necessary depending on the outcome of the occlusion query.
The occluded area returned by the
GetUnoccludedAreafunction is reported as the fraction of the entire viewport area corresponding to the number of fragments that passed the depth test. It is always in the range [0.0, 1.0], where a value of 0.0 means that no fragments passed the depth test, and a value of 1.0 means that the entire viewport was filled with fragments that did pass the depth test.
||Used internally by the Graphics Manager.|