source: trunk/VUT/work/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h @ 88

Revision 88, 5.4 KB checked in by mattausch, 19 years ago (diff)
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://ogre.sourceforge.net/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef _HardwareOcclusionQuery__
26#define _HardwareOcclusionQuery__
27
28// Precompiler options
29#include "OgrePrerequisites.h"
30
31namespace Ogre {
32
33
34/**
35  * Hardware occlusion query flags
36  */
37typedef enum _OCCLUSIONQUERY
38{
39        HWOCCLUSIONQUERY_FLUSH,   /** Direct3D uses this, but not OpenGL */
40        HWOCCLUSIONQUERY_NOFLUSH, /** To decide if the driver should flush all batched API calls to serve an occlusion query faster. */
41} HW_OCCLUSIONQUERY;
42
43/**
44  * This is a abstract class that that provides the interface for the query class for
45  * hardware occlusion.
46  *
47  * @author Lee Sandberg
48  */
49class _OgreExport HardwareOcclusionQuery
50{
51//----------------------------------------------------------------------
52// Public methods
53//--
54public:
55        /**
56          * Object public member functions
57          */
58
59        /**
60          * Default object constructor
61          *
62          */
63        HardwareOcclusionQuery();
64
65        /**
66          * Object destructor
67          */
68        virtual ~HardwareOcclusionQuery();
69
70        /**
71          * Starts the hardware occlusion query
72          * @Remarks    Simple usage: Create one or more OcclusionQuery object one per outstanding query or one per tested object
73          *                             OcclusionQuery* m_pOcclusionQuery;
74          *                             createOcclusionQuery( &m_pOcclusionQuery );
75          *                             In the rendering loop:
76          *                             Draw all occluders
77          *                             m_pOcclusionQuery->startOcclusionQuery();
78          *                             Draw the polygons to be tested
79          *                             m_pOcclusionQuery->endOcclusionQuery();
80          *
81          *                             Results must be pulled using:
82          *                             UINT    m_uintNumberOfPixelsVisable;
83          *                             pullOcclusionQuery( &m_dwNumberOfPixelsVisable );
84          *                             You may not get the result directlly after the first pass or frame.
85          *                             Objects not visable must be tested every frame, visable objects may be tested less freqvent.
86          *                     
87          */
88        virtual void beginOcclusionQuery() = 0;
89
90        /**
91          * Ends the hardware occlusion test
92          */
93        virtual void endOcclusionQuery() = 0;
94
95        /**
96      * Pulls the hardware occlusion query too see if there is a result.
97      * @retval NumOfFragments will get the resulting number of fragments.
98      * @return True if success or false if not.
99          * @Remarks Hardware occlusion is an assyncronius process the result may take a frame or so.
100          *                     one idea is to test pass1 and if not visable skip pass2. Also note that objects
101          *                     not visable must be tested evrey frame. Visable objects don't need testing every frame.
102          *                     Testing non visable objects can be don unlit, no texture with low LOD object.
103          *        0 will generate all the levels till 1x1. [default: 0]
104      */
105        virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult ) = 0;
106
107        /**
108      * Pulls the hardware occlusion query too see if there is a result.
109      * @retval NumOfFragments will get the resulting number of fragments.
110      * @return True if success or false if not.
111          * @Remarks In DX9 mode specifying OCCLUSIONQUERY_FLUSH as the flag, will case the driver to flush whatever API calls are batched.
112          * In OpenGL mode it makes no difference if you specify OCCLUSIONQUERY_FLUSH or OCCLUSIONQUERY_NOFLUSH.
113      */
114        virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,
115                                                                         const HW_OCCLUSIONQUERY flag  ) = 0;
116
117        /**
118          * Let's you get the last pixel count with out doing the hardware occlusion test
119          * @return The last fragment count from the last test.
120          * Remarks This function won't give you new values, just the old value.
121          */
122        virtual unsigned int getLastQuerysPixelcount() = 0;
123
124        /**
125          *   
126          * @Remarks This function allows you to set how often the hardware occlusion really are sent to the driver
127          * if you set it to 0 every hw occlusion test is acctually made. If you set it to 1 only the half of your queries are sent
128          * for all visable objects. 2 will result in 25% of all queries to acctualy be sent.
129          * New and none visable objects will be tested all the time.
130          * This functionality is here because this class can keep track on visable and none visable objects for you.
131          * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
132          */
133
134        virtual void    setSkipRate( int skip ) = 0;
135        virtual int             getSkipRate() = 0;
136//----------------------------------------------------------------------
137// Private members
138//--
139private:
140
141};
142
143}
144#endif
145
Note: See TracBrowser for help on using the repository browser.