/src/ogre/OgreMain/include/OgreHardwareOcclusionQuery.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | #ifndef _HardwareOcclusionQuery__ |
29 | | #define _HardwareOcclusionQuery__ |
30 | | |
31 | | // Precompiler options |
32 | | #include "OgrePrerequisites.h" |
33 | | |
34 | | namespace Ogre { |
35 | | |
36 | | |
37 | | |
38 | | /** \addtogroup Core |
39 | | * @{ |
40 | | */ |
41 | | /** \addtogroup RenderSystem |
42 | | * @{ |
43 | | */ |
44 | | /** |
45 | | * Query how many pixels have passed the per-fragment tests. |
46 | | * |
47 | | * Create one OcclusionQuery per outstanding query or one per tested object |
48 | | * |
49 | | * Then, in the rendering loop: |
50 | | * 1. Draw all occluders |
51 | | * 2. @ref begin() |
52 | | * 3. Draw the polygons to be tested |
53 | | * 4. @ref end() |
54 | | * |
55 | | * Results must be pulled using @ref waitForResult() |
56 | | */ |
57 | | class _OgreExport HardwareOcclusionQuery : public RenderSysAlloc |
58 | | { |
59 | | public: |
60 | | HardwareOcclusionQuery(); |
61 | | |
62 | | virtual ~HardwareOcclusionQuery(); |
63 | | |
64 | | /** |
65 | | * Starts the hardware occlusion query |
66 | | */ |
67 | 0 | void begin() { beginOcclusionQuery(); } |
68 | | virtual void beginOcclusionQuery() = 0; |
69 | | |
70 | | /** |
71 | | * Ends the hardware occlusion test |
72 | | */ |
73 | 0 | void end() { endOcclusionQuery(); } |
74 | | virtual void endOcclusionQuery() = 0; |
75 | | |
76 | | /** |
77 | | * Waits until the query result is available. |
78 | | * use @ref resultReady() if just want to test if the result is available. |
79 | | * @retval result will get the resulting number of fragments. |
80 | | * @return True if success or false if not. |
81 | | */ |
82 | 0 | bool waitForResult(unsigned int* result) { return pullOcclusionQuery(result); } |
83 | | virtual bool pullOcclusionQuery(unsigned int* result) = 0; |
84 | | |
85 | | /** |
86 | | * Let's you get the last pixel count with out doing the hardware occlusion test. |
87 | | * This function won't give you new values, just the old value. |
88 | | * @return The last fragment count from the last test. |
89 | | */ |
90 | 0 | uint32 getLastResult() const { return mPixelCount; } |
91 | 0 | OGRE_DEPRECATED uint32 getLastQuerysPixelcount() const { return getLastResult(); } |
92 | | |
93 | | /** |
94 | | * Lets you know when query is done, or still be processed by the Hardware |
95 | | * @return true if query is finished. |
96 | | */ |
97 | 0 | bool resultReady() { return !isStillOutstanding(); } |
98 | | virtual bool isStillOutstanding(void) = 0; |
99 | | |
100 | | protected: |
101 | | /// Number of visible pixels determined by last query |
102 | | uint32 mPixelCount; |
103 | | /// Has the query returned a result yet? |
104 | | bool mIsQueryResultStillOutstanding; |
105 | | }; |
106 | | |
107 | | /** @} */ |
108 | | /** @} */ |
109 | | } |
110 | | #endif |
111 | | |