[61] | 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 |
|
---|
| 26 | #ifndef _D3D9HARWAREOCCLUSIONQUERY_H__
|
---|
| 27 | #define _D3D9HARWAREOCCLUSIONQUERY_H__
|
---|
| 28 |
|
---|
| 29 | #include "OgreD3D9Prerequisites.h"
|
---|
| 30 | #include "OgreHardwareOcclusionQuery.h"
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | namespace Ogre {
|
---|
| 34 |
|
---|
| 35 | // If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered
|
---|
[115] | 36 | // if the first pass resultet has too few pixels visible.
|
---|
[61] | 37 |
|
---|
| 38 | // Be sure to render all occlluder first and whats out so the RenderQue don't switch places on
|
---|
| 39 | // the occluding objects and the tested objects because it thinks it's more effective..
|
---|
| 40 |
|
---|
| 41 | /**
|
---|
| 42 | * This is a class that is the DirectX9 implementation of
|
---|
| 43 | * hardware occlusion testing.
|
---|
| 44 | *
|
---|
| 45 | * @author Lee Sandberg, email lee@abcmedia.se
|
---|
[115] | 46 | *
|
---|
| 47 | * Updated on 12/7/2004 by Chris McGuirk
|
---|
[61] | 48 | */
|
---|
| 49 | class D3D9HardwareOcclusionQuery : public HardwareOcclusionQuery
|
---|
| 50 | {
|
---|
| 51 | //----------------------------------------------------------------------
|
---|
| 52 | // Public methods
|
---|
| 53 | //--
|
---|
| 54 | public:
|
---|
| 55 |
|
---|
| 56 | /**
|
---|
| 57 | * Default object constructor
|
---|
| 58 | *
|
---|
| 59 | */
|
---|
| 60 | D3D9HardwareOcclusionQuery( IDirect3DDevice9* pD3DDevice );
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
| 63 | * Object destructor
|
---|
| 64 | */
|
---|
| 65 | ~D3D9HardwareOcclusionQuery();
|
---|
| 66 |
|
---|
| 67 | //------------------------------------------------------------------
|
---|
| 68 | // Occlusion query functions (see base class documentation for this)
|
---|
| 69 | //--
|
---|
| 70 |
|
---|
| 71 | void beginOcclusionQuery();
|
---|
| 72 | void endOcclusionQuery();
|
---|
[115] | 73 | bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH);
|
---|
| 74 | unsigned int getLastQuerysPixelcount() { return mPixelCount; }
|
---|
[92] | 75 |
|
---|
[115] | 76 | // These functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only
|
---|
| 77 | // It's easy to use if you don't have to keep track of which objects are visible (can be skipped) and what objects arn't visible..
|
---|
| 78 | // (None visible objects and object you introduce for the first time have always to be tested although the cheapest possible
|
---|
| 79 | // LOD (Level Of Detail) mesh and material-wise).
|
---|
[88] | 80 |
|
---|
[61] | 81 | /**
|
---|
| 82 | *
|
---|
[115] | 83 | * Remarks This function allows you to set how often the hardware occlusion query is sent to the driver
|
---|
[61] | 84 | * 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] | 85 | * 2 will result in 25% of all queries to acctualy be sent.
|
---|
| 86 | * This functionality is here because this class can keep track on visible and none visible objects for you.
|
---|
[61] | 87 | * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
|
---|
| 88 | */
|
---|
| 89 |
|
---|
[115] | 90 | void setSkipRate( int skip ) { mSkipInterval = skip; } // Using 2 only 50 % of the tests are actully made and 3 results in only 33% of the tests. So on.
|
---|
| 91 | int getSkipRate() { return mSkipInterval; }
|
---|
[61] | 92 |
|
---|
[115] | 93 | #ifdef GTP_VISIBILITY_MODIFIED_OGRE
|
---|
| 94 | bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH );
|
---|
| 95 | #endif // GTP_VISIBILITY_MODIFIED_OGRE
|
---|
[61] | 96 | //----------------------------------------------------------------------
|
---|
| 97 | // Protected members
|
---|
| 98 | //--
|
---|
| 99 | protected:
|
---|
| 100 |
|
---|
[115] | 101 | unsigned int mPixelCount;
|
---|
| 102 | IDirect3DQuery9* mpQuery;
|
---|
| 103 | IDirect3DDevice9* mpDevice;
|
---|
| 104 | int mSkipCounter;
|
---|
| 105 | int mSkipInterval;
|
---|
| 106 | bool mHasOcclusionSupport;
|
---|
[61] | 107 | };
|
---|
| 108 |
|
---|
| 109 |
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | #endif
|
---|