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 | * This is a abstract class that that provides the interface for the query class for
|
---|
35 | * hardware occlusion.
|
---|
36 | *
|
---|
37 | * @author Lee Sandberg
|
---|
38 | * Updated on 13/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr
|
---|
39 | */
|
---|
40 | class _OgreExport HardwareOcclusionQuery
|
---|
41 | {
|
---|
42 | //----------------------------------------------------------------------
|
---|
43 | // Public methods
|
---|
44 | //--
|
---|
45 | public:
|
---|
46 | /**
|
---|
47 | * Object public member functions
|
---|
48 | */
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Default object constructor
|
---|
52 | *
|
---|
53 | */
|
---|
54 | HardwareOcclusionQuery();
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * Object destructor
|
---|
58 | */
|
---|
59 | virtual ~HardwareOcclusionQuery();
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * Starts the hardware occlusion query
|
---|
63 | * @Remarks Simple usage: Create one or more OcclusionQuery object one per outstanding query or one per tested object
|
---|
64 | * OcclusionQuery* m_pOcclusionQuery;
|
---|
65 | * createOcclusionQuery( &m_pOcclusionQuery );
|
---|
66 | * In the rendering loop:
|
---|
67 | * Draw all occluders
|
---|
68 | * m_pOcclusionQuery->startOcclusionQuery();
|
---|
69 | * Draw the polygons to be tested
|
---|
70 | * m_pOcclusionQuery->endOcclusionQuery();
|
---|
71 | *
|
---|
72 | * Results must be pulled using:
|
---|
73 | * UINT m_uintNumberOfPixelsVisable;
|
---|
74 | * pullOcclusionQuery( &m_dwNumberOfPixelsVisable );
|
---|
75 | *
|
---|
76 | */
|
---|
77 | virtual void beginOcclusionQuery() = 0;
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Ends the hardware occlusion test
|
---|
81 | */
|
---|
82 | virtual void endOcclusionQuery() = 0;
|
---|
83 |
|
---|
84 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE_DUMPED
|
---|
85 | /**
|
---|
86 | Pulls occlusion query.
|
---|
87 | @param NumOfFragments number of visible fragments if query result was available.
|
---|
88 | Last query result if query result was not yet available.
|
---|
89 |
|
---|
90 | @param waitForResult if true, the function waits until the result is available.
|
---|
91 | Otherwise the function returns immediately, not waiting for the result.
|
---|
92 | @returns true if query result was available, false if result was not yet available
|
---|
93 | */
|
---|
94 | virtual bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult) = 0;
|
---|
95 | #endif // GTP_VISIBILITY_MODIFIED_OGRE
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Pulls the hardware occlusion query too see if there is a result.
|
---|
99 | * @retval NumOfFragments will get the resulting number of fragments.
|
---|
100 | * @return True if success or false if not.
|
---|
101 | */
|
---|
102 | virtual bool pullOcclusionQuery(unsigned int* NumOfFragments) = 0;
|
---|
103 |
|
---|
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 | unsigned int getLastQuerysPixelcount() const { return mPixelCount; }
|
---|
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 isStillOutstanding(void) = 0;
|
---|
117 |
|
---|
118 |
|
---|
119 | //----------------------------------------------------------------------
|
---|
120 | // protected members
|
---|
121 | //--
|
---|
122 | protected :
|
---|
123 | // numbers of visible pixels determined by last query
|
---|
124 | unsigned int mPixelCount;
|
---|
125 | // is query hasn't yet returned a result.
|
---|
126 | bool mIsQueryResultStillOutstanding;
|
---|
127 | };
|
---|
128 |
|
---|
129 | }
|
---|
130 | #endif
|
---|
131 |
|
---|