[148] | 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-2013 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 | * This is a abstract class that that provides the interface for the query class for |
---|
| 46 | * hardware occlusion. |
---|
| 47 | * |
---|
| 48 | * @author Lee Sandberg |
---|
| 49 | * Updated on 13/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr |
---|
| 50 | */ |
---|
| 51 | class _OgreExport HardwareOcclusionQuery : public RenderSysAlloc |
---|
| 52 | { |
---|
| 53 | //---------------------------------------------------------------------- |
---|
| 54 | // Public methods |
---|
| 55 | //-- |
---|
| 56 | public: |
---|
| 57 | /** |
---|
| 58 | * Object public member functions |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | * Default object constructor |
---|
| 63 | * |
---|
| 64 | */ |
---|
| 65 | HardwareOcclusionQuery(); |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * Object destructor |
---|
| 69 | */ |
---|
| 70 | virtual ~HardwareOcclusionQuery(); |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Starts the hardware occlusion query |
---|
| 74 | * @remarks Simple usage: Create one or more OcclusionQuery object one per outstanding query or one per tested object |
---|
| 75 | * OcclusionQuery* mOcclusionQuery; |
---|
| 76 | * createOcclusionQuery( &mOcclusionQuery ); |
---|
| 77 | * In the rendering loop: |
---|
| 78 | * Draw all occluders |
---|
| 79 | * mOcclusionQuery->startOcclusionQuery(); |
---|
| 80 | * Draw the polygons to be tested |
---|
| 81 | * mOcclusionQuery->endOcclusionQuery(); |
---|
| 82 | * |
---|
| 83 | * Results must be pulled using: |
---|
| 84 | * UINT mNumberOfPixelsVisable; |
---|
| 85 | * pullOcclusionQuery( &mNumberOfPixelsVisable ); |
---|
| 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. |
---|
| 97 | * @note Waits until the query result is available; use isStillOutstanding |
---|
| 98 | * if just want to test if the result is available. |
---|
| 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 | * 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 | unsigned int getLastQuerysPixelcount() const { return mPixelCount; } |
---|
| 110 | |
---|
| 111 | /** |
---|
| 112 | * Lets you know when query is done, or still be processed by the Hardware |
---|
| 113 | * @return true if query isn't finished. |
---|
| 114 | */ |
---|
| 115 | virtual bool isStillOutstanding(void) = 0; |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | //---------------------------------------------------------------------- |
---|
| 119 | // protected members |
---|
| 120 | //-- |
---|
| 121 | protected : |
---|
| 122 | /// Number of visible pixels determined by last query |
---|
| 123 | unsigned int mPixelCount; |
---|
| 124 | /// Has the query returned a result yet? |
---|
| 125 | bool mIsQueryResultStillOutstanding; |
---|
| 126 | }; |
---|
| 127 | |
---|
| 128 | /** @} */ |
---|
| 129 | /** @} */ |
---|
| 130 | } |
---|
| 131 | #endif |
---|
| 132 | |
---|