source: OGRE/trunk/ogre_changes/OgreMain/include/OgreHardwareOcclusionQuery.h @ 657

Revision 657, 5.4 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

RevLine 
[61]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
[657]48  * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr
[61]49  */
50class _OgreExport HardwareOcclusionQuery
51{
52//----------------------------------------------------------------------
53// Public methods
54//--
55public:
56        /**
57          * Object public member functions
58          */
59
60        /**
61          * Default object constructor
62          *
63          */
64        HardwareOcclusionQuery();
65
66        /**
67          * Object destructor
68          */
69        virtual ~HardwareOcclusionQuery();
70
71        /**
72          * Starts the hardware occlusion query
73          * @Remarks    Simple usage: Create one or more OcclusionQuery object one per outstanding query or one per tested object
74          *                             OcclusionQuery* m_pOcclusionQuery;
75          *                             createOcclusionQuery( &m_pOcclusionQuery );
76          *                             In the rendering loop:
77          *                             Draw all occluders
78          *                             m_pOcclusionQuery->startOcclusionQuery();
79          *                             Draw the polygons to be tested
80          *                             m_pOcclusionQuery->endOcclusionQuery();
81          *
82          *                             Results must be pulled using:
83          *                             UINT    m_uintNumberOfPixelsVisable;
84          *                             pullOcclusionQuery( &m_dwNumberOfPixelsVisable );
[657]85          *                             You may not get the result directly after the first pass or frame.
86          *                             Objects not visible must be tested every frame, visible objects may be tested less frequently.
[61]87          *                     
88          */
89        virtual void beginOcclusionQuery() = 0;
90
91        /**
92          * Ends the hardware occlusion test
93          */
94        virtual void endOcclusionQuery() = 0;
95
96        /**
97      * Pulls the hardware occlusion query too see if there is a result.
98      * @retval NumOfFragments will get the resulting number of fragments.
99      * @return True if success or false if not.
100          * @Remarks In DX9 mode specifying OCCLUSIONQUERY_FLUSH as the flag, will case the driver to flush whatever API calls are batched.
101          * In OpenGL mode it makes no difference if you specify OCCLUSIONQUERY_FLUSH or OCCLUSIONQUERY_NOFLUSH.
102      */
[115]103        virtual bool pullOcclusionQuery(unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH) = 0;
104
[61]105        /**
106          * Let's you get the last pixel count with out doing the hardware occlusion test
107          * @return The last fragment count from the last test.
108          * Remarks This function won't give you new values, just the old value.
109          */
110        virtual unsigned int getLastQuerysPixelcount() = 0;
111
112        /**
113          *   
114          * @Remarks This function allows you to set how often the hardware occlusion really are sent to the driver
[657]115          * if you set it to 0 every hardware occlusion test is actually made. If you set it to 1 only the half of your queries are sent
116          * for all visible objects. 2 will result in 25% of all queries to actually be sent.
117          * New and none visible objects will be tested all the time.
118          * This functionality is here because this class can keep track on visible and none visible objects for you.
[61]119          * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
120          */
121
122        virtual void    setSkipRate( int skip ) = 0;
123        virtual int             getSkipRate() = 0;
[115]124
125#ifdef GTP_VISIBILITY_MODIFIED_OGRE
126        /**
127                Pulls occlusion query.
128                @param NumOfFragments number of visible fragments if query result was available.
129                Last query result if query result was not yet available.
130
131                @param waitForResult if true, the function waits until the result is available.
132                Otherwise the function returns immediately, not waiting for the result.
133                @returns true if query result was available, false if result was not yet available
134        */
135        virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,
136                const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH ) = 0;
137#endif // GTP_VISIBILITY_MODIFIED_OGRE
138
[61]139//----------------------------------------------------------------------
140// Private members
141//--
142private:
143
144};
145
146}
147#endif
148
Note: See TracBrowser for help on using the repository browser.