[3] | 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-2006 Torus Knot Software Ltd |
---|
| 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 | You may alternatively use this source under the terms of a specific version of |
---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
| 26 | Torus Knot Software Ltd. |
---|
| 27 | ----------------------------------------------------------------------------- |
---|
| 28 | */ |
---|
| 29 | #ifndef _HardwareOcclusionQuery__ |
---|
| 30 | #define _HardwareOcclusionQuery__ |
---|
| 31 | |
---|
| 32 | // Precompiler options |
---|
| 33 | #include "OgrePrerequisites.h" |
---|
| 34 | |
---|
| 35 | namespace Ogre { |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * This is a abstract class that that provides the interface for the query class for |
---|
| 41 | * hardware occlusion. |
---|
| 42 | * |
---|
| 43 | * @author Lee Sandberg |
---|
| 44 | * Updated on 13/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr |
---|
| 45 | */ |
---|
| 46 | class _OgreExport HardwareOcclusionQuery |
---|
| 47 | { |
---|
| 48 | //---------------------------------------------------------------------- |
---|
| 49 | // Public methods |
---|
| 50 | //-- |
---|
| 51 | public: |
---|
| 52 | /** |
---|
| 53 | * Object public member functions |
---|
| 54 | */ |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * Default object constructor |
---|
| 58 | * |
---|
| 59 | */ |
---|
| 60 | HardwareOcclusionQuery(); |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | * Object destructor |
---|
| 64 | */ |
---|
| 65 | virtual ~HardwareOcclusionQuery(); |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * Starts the hardware occlusion query |
---|
| 69 | * @Remarks Simple usage: Create one or more OcclusionQuery object one per outstanding query or one per tested object |
---|
| 70 | * OcclusionQuery* m_pOcclusionQuery; |
---|
| 71 | * createOcclusionQuery( &m_pOcclusionQuery ); |
---|
| 72 | * In the rendering loop: |
---|
| 73 | * Draw all occluders |
---|
| 74 | * m_pOcclusionQuery->startOcclusionQuery(); |
---|
| 75 | * Draw the polygons to be tested |
---|
| 76 | * m_pOcclusionQuery->endOcclusionQuery(); |
---|
| 77 | * |
---|
| 78 | * Results must be pulled using: |
---|
| 79 | * UINT m_uintNumberOfPixelsVisable; |
---|
| 80 | * pullOcclusionQuery( &m_dwNumberOfPixelsVisable ); |
---|
| 81 | * |
---|
| 82 | */ |
---|
| 83 | virtual void beginOcclusionQuery() = 0; |
---|
| 84 | |
---|
| 85 | /** |
---|
| 86 | * Ends the hardware occlusion test |
---|
| 87 | */ |
---|
| 88 | virtual void endOcclusionQuery() = 0; |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | * Pulls the hardware occlusion query. |
---|
| 92 | * @note Waits until the query result is available; use isStillOutstanding |
---|
| 93 | * if just want to test if the result is available. |
---|
| 94 | * @retval NumOfFragments will get the resulting number of fragments. |
---|
| 95 | * @return True if success or false if not. |
---|
| 96 | */ |
---|
| 97 | virtual bool pullOcclusionQuery(unsigned int* NumOfFragments) = 0; |
---|
| 98 | |
---|
| 99 | /** |
---|
| 100 | * Let's you get the last pixel count with out doing the hardware occlusion test |
---|
| 101 | * @return The last fragment count from the last test. |
---|
| 102 | * Remarks This function won't give you new values, just the old value. |
---|
| 103 | */ |
---|
| 104 | unsigned int getLastQuerysPixelcount() const { return mPixelCount; } |
---|
| 105 | |
---|
| 106 | /** |
---|
| 107 | * Lets you know when query is done, or still be processed by the Hardware |
---|
| 108 | * @return true if query isn't finished. |
---|
| 109 | */ |
---|
| 110 | virtual bool isStillOutstanding(void) = 0; |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | //---------------------------------------------------------------------- |
---|
| 114 | // protected members |
---|
| 115 | //-- |
---|
| 116 | protected : |
---|
| 117 | // numbers of visible pixels determined by last query |
---|
| 118 | unsigned int mPixelCount; |
---|
| 119 | // is query hasn't yet returned a result. |
---|
| 120 | bool mIsQueryResultStillOutstanding; |
---|
| 121 | }; |
---|
| 122 | |
---|
| 123 | } |
---|
| 124 | #endif |
---|
| 125 | |
---|