PixelLightAPI  .
Public Member Functions | Protected Member Functions
PLRenderer::OcclusionQuery Class Reference

Abstract renderer occlusion query. More...

#include <OcclusionQuery.h>

Inheritance diagram for PLRenderer::OcclusionQuery:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual PLRENDERER_API ~OcclusionQuery ()
 Destructor.
virtual bool BeginOcclusionQuery ()=0
 Starts the hardware occlusion query.
virtual void EndOcclusionQuery ()=0
 Ends the hardware occlusion query.
virtual bool PullOcclusionQuery (PLCore::uint32 *pnNumOfFragments=nullptr)=0
 Pulls the hardware occlusion query too see if there is a result.
virtual PLCore::uint32 GetLastQuerysPixelCount () const =0
 Returns the number of the last occlusion query visible fragments.
virtual PLCore::uint32 GetSkipRate () const =0
 Returns the skip rate.
virtual void SetSkipRate (PLCore::uint32 nRate=0)=0
 Sets the skip rate.
virtual PLCore::uint32 GetMinFragments () const =0
 Gets the minimum number of visible fragments.
virtual void SetMinFragments (PLCore::uint32 nMinFragments=0)=0
 Sets the minimum number of visible fragments.

Protected Member Functions

PLRENDERER_API OcclusionQuery (Renderer &cRenderer)
 Constructor.

Detailed Description

Abstract renderer occlusion query.

*    Usage example:
*    Create one or more OcclusionQuery object one per outstanding
*    query or one per tested object.
*
*    OcclusionQuery *pOcclusionQuery = cRenderer.CreateOcclusionQuery();
*    // In the rendering loop:
*    // Draw all occludes
*    pOcclusionQuery->BeginOcclusionQuery();
*    // Draw the polygons to be tested
*    pOcclusionQuery->EndOcclusionQuery();
*    // Do something useful to give the GPU some time to process the stuff
*    // Results must be pulled using:
*    PLCore::uint32 nNumberOfVisibleFragments;
*    if (!pOcclusionQuery->PullOcclusionQuery(&nNumberOfVisibleFragments)) {
*      if (nNumberOfVisibleFragments >= pOcclusionQuery->GetMinFragments()) {
*        // Our object is visible (or visible enough ;-)
*      }
*    } else {
*       // The result isn't available yet! We still have to wait for it...
*    }
*  

Constructor & Destructor Documentation

virtual PLRENDERER_API PLRenderer::OcclusionQuery::~OcclusionQuery ( ) [virtual]

Destructor.

PLRENDERER_API PLRenderer::OcclusionQuery::OcclusionQuery ( Renderer cRenderer) [protected]

Constructor.

Parameters:
[in]cRendererThe owner renderer

Member Function Documentation

virtual bool PLRenderer::OcclusionQuery::BeginOcclusionQuery ( ) [pure virtual]

Starts the hardware occlusion query.

Returns:
'true' if all went fine and the occlusion query was started, else 'false' (maybe occlusion query is not supported or skip rate is active)
virtual void PLRenderer::OcclusionQuery::EndOcclusionQuery ( ) [pure virtual]

Ends the hardware occlusion query.

virtual bool PLRenderer::OcclusionQuery::PullOcclusionQuery ( PLCore::uint32 *  pnNumOfFragments = nullptr) [pure virtual]

Pulls the hardware occlusion query too see if there is a result.

Parameters:
[out]pnNumOfFragmentsIf not a null pointer it will receive the number of visible fragments
Returns:
'true' if all went fine, else 'false' (the queried data isn't available yet)
Note:
  • Hardware occlusion is an asynchronous process the result may take a frame or so. one idea is to test pass 1 and if not visible skip pass 2. Also note that objects which are not visible must be tested every frame. Visible objects don't need testing every frame. Testing non visible objects can be don unlit, no texture with low LOD object - this is also the case when using for instance only a bounding box for a complex mesh.
  • After BeginOcclusionQuery()/EndOcclusionQuery() you should do some other stuff before asking for the result using this function to give the GPU some time to process the the stuff. If this function returns 'true' then you still have to wait for the result!
See also:
virtual PLCore::uint32 PLRenderer::OcclusionQuery::GetLastQuerysPixelCount ( ) const [pure virtual]

Returns the number of the last occlusion query visible fragments.

Returns:
The fragment count from the last test
virtual PLCore::uint32 PLRenderer::OcclusionQuery::GetSkipRate ( ) const [pure virtual]

Returns the skip rate.

Returns:
Current skip rate
Remarks:
This function allows you to set how often the hardware occlusion really are sent to the driver if you set it to 0 every hw occlusion test is actually made. If you set it to 1 only the half of your queries are sent for all visible objects. 2 will result in 25% of all queries to actually be sent which will result in a better performance. New and none visible objects will be tested all the time. This class can keep track on visible and none visible objects for you.
virtual void PLRenderer::OcclusionQuery::SetSkipRate ( PLCore::uint32  nRate = 0) [pure virtual]

Sets the skip rate.

Parameters:
[in]nRateNew skip rate
See also:
virtual PLCore::uint32 PLRenderer::OcclusionQuery::GetMinFragments ( ) const [pure virtual]

Gets the minimum number of visible fragments.

Returns:
Minimum number of visible fragments
Remarks:
This setting indicates when something can be seen as invisible. For instance often you can see something as invisible if less then e.g. 10 fragments are visible without a visual quality impact.
virtual void PLRenderer::OcclusionQuery::SetMinFragments ( PLCore::uint32  nMinFragments = 0) [pure virtual]

Sets the minimum number of visible fragments.

Parameters:
[in]nMinFragmentsMinimum number of visible fragments
See also:

The documentation for this class was generated from the following file:


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:23
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported