1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://ogre.sourceforge.net/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef _HardwareOcclusionQuery__
|
---|
26 | #define _HardwareOcclusionQuery__
|
---|
27 |
|
---|
28 | // Precompiler options
|
---|
29 | #include "OgrePrerequisites.h"
|
---|
30 |
|
---|
31 | namespace Ogre {
|
---|
32 |
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Hardware occlusion query flags
|
---|
36 | */
|
---|
37 | typedef 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 | * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr
|
---|
49 | */
|
---|
50 | class _OgreExport HardwareOcclusionQuery
|
---|
51 | {
|
---|
52 | //----------------------------------------------------------------------
|
---|
53 | // Public methods
|
---|
54 | //--
|
---|
55 | public:
|
---|
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 );
|
---|
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.
|
---|
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 | */
|
---|
103 | virtual bool pullOcclusionQuery(unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH) = 0;
|
---|
104 |
|
---|
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 | * Lets you know when query is done, or still be processed by the Hardware
|
---|
114 | * @return true if query isn't finished.
|
---|
115 | */
|
---|
116 | virtual bool HardwareOcclusionQuery::isStillOutstanding(void) = 0;
|
---|
117 | /**
|
---|
118 | *
|
---|
119 | * @Remarks This function allows you to set how often the hardware occlusion really are sent to the driver
|
---|
120 | * 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
|
---|
121 | * for all visible objects. 2 will result in 25% of all queries to actually be sent.
|
---|
122 | * New and none visible objects will be tested all the time.
|
---|
123 | * This functionality is here because this class can keep track on visible and none visible objects for you.
|
---|
124 | * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
|
---|
125 | */
|
---|
126 |
|
---|
127 | virtual void setSkipRate( int skip ) = 0;
|
---|
128 | virtual int getSkipRate() = 0;
|
---|
129 |
|
---|
130 | //----------------------------------------------------------------------
|
---|
131 | // Private members
|
---|
132 | //--
|
---|
133 | private:
|
---|
134 |
|
---|
135 | };
|
---|
136 |
|
---|
137 | }
|
---|
138 | #endif
|
---|
139 |
|
---|