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 | */
|
---|
49 | class _OgreExport HardwareOcclusionQuery
|
---|
50 | {
|
---|
51 | //----------------------------------------------------------------------
|
---|
52 | // Public methods
|
---|
53 | //--
|
---|
54 | public:
|
---|
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 In DX9 mode specifying OCCLUSIONQUERY_FLUSH as the flag, will case the driver to flush whatever API calls are batched.
|
---|
100 | * In OpenGL mode it makes no difference if you specify OCCLUSIONQUERY_FLUSH or OCCLUSIONQUERY_NOFLUSH.
|
---|
101 | */
|
---|
102 | virtual bool pullOcclusionQuery(unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH) = 0;
|
---|
103 |
|
---|
104 | /**
|
---|
105 | * Let's you get the last pixel count with out doing the hardware occlusion test
|
---|
106 | * @return The last fragment count from the last test.
|
---|
107 | * Remarks This function won't give you new values, just the old value.
|
---|
108 | */
|
---|
109 | virtual unsigned int getLastQuerysPixelcount() = 0;
|
---|
110 |
|
---|
111 | /**
|
---|
112 | *
|
---|
113 | * @Remarks This function allows you to set how often the hardware occlusion really are sent to the driver
|
---|
114 | * 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
|
---|
115 | * for all visable objects. 2 will result in 25% of all queries to acctualy be sent.
|
---|
116 | * New and none visable objects will be tested all the time.
|
---|
117 | * This functionality is here because this class can keep track on visable and none visable objects for you.
|
---|
118 | * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
|
---|
119 | */
|
---|
120 |
|
---|
121 | virtual void setSkipRate( int skip ) = 0;
|
---|
122 | virtual int getSkipRate() = 0;
|
---|
123 |
|
---|
124 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE
|
---|
125 | /**
|
---|
126 | Pulls occlusion query.
|
---|
127 | @param NumOfFragments number of visible fragments if query result was available.
|
---|
128 | Last query result if query result was not yet available.
|
---|
129 |
|
---|
130 | @param waitForResult if true, the function waits until the result is available.
|
---|
131 | Otherwise the function returns immediately, not waiting for the result.
|
---|
132 | @returns true if query result was available, false if result was not yet available
|
---|
133 | */
|
---|
134 | virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult,
|
---|
135 | const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH ) = 0;
|
---|
136 | #endif // GTP_VISIBILITY_MODIFIED_OGRE
|
---|
137 |
|
---|
138 | //----------------------------------------------------------------------
|
---|
139 | // Private members
|
---|
140 | //--
|
---|
141 | private:
|
---|
142 |
|
---|
143 | };
|
---|
144 |
|
---|
145 | }
|
---|
146 | #endif
|
---|
147 |
|
---|