source: OGRE/trunk/ogrenew/RenderSystems/GL/include/OgreGLHardwareOcclusionQuery.h @ 657

Revision 657, 5.0 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://ogre.sourceforge.net/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26/*
27The nVidia occlusion query extension is defined in glext.h so you don't
28need anything else. You do need to look up the function, we provide a
29GLSupport class to do this, which has platform implementations for
30getProcAddress. Check the way that extensions like glActiveTextureARB are
31initialised and used in glRenderSystem and copy what is done there.
32
33
34
35  To do: fix so dx7 and DX9 checks and flags if HW Occlusion is supported
36  See the openGl dito for ideas what to do.
37
38*/
39
40
41
42//GL_ActiveTextureARB_Func* glActiveTextureARB_ptr = (GL_ActiveTextureARB_Func)mGLSupport->getProcAddress("glActiveTextureARB");
43
44#ifndef __GLHARDWAREOCCLUSIONQUERY_H__
45#define __GLHARDWAREOCCLUSIONQUERY_H__
46
47#include "OgreGLPrerequisites.h"
48#include "OgreHardwareOcclusionQuery.h"
49
50
51namespace Ogre {
52
53
54// If you use multiple rendering passes you can test only the first pass and all other passes don't have to be rendered
55// if the first pass result has too few pixels visible.
56
57// Be sure to render all occluder first and whats out so the RenderQue don't switch places on
58// the occluding objects and the tested objects because it thinks it's more effective..
59
60
61/**
62  * This is a class that is the base class of the query class for
63  * hardware occlusion.
64  *
65  * @author Lee Sandberg email: lee@abcmedia.se
66  * Updated on 4/8/2005 by Tuan Kuranes email: tuan.kuranes@free.fr
67  */
68
69class GLHardwareOcclusionQuery : public HardwareOcclusionQuery
70{
71//----------------------------------------------------------------------
72// Public methods
73//--
74public:
75        /**
76          * Default object constructor
77          *
78          */
79        GLHardwareOcclusionQuery();
80        /**
81          * Object destructor
82          */
83        ~GLHardwareOcclusionQuery();
84
85        //------------------------------------------------------------------
86        // Occlusion query functions (see base class documentation for this)
87        //--
88
89        void beginOcclusionQuery();
90        void endOcclusionQuery();
91        bool pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  );
92        unsigned int getLastQuerysPixelcount() { return mPixelCount; }
93
94        // This functions are optional, it's a simple filter that simply skips some hardware occlusion tests on visible objects only
95        // It's easy to use if you don't have to keep track on which objects are visible (can be skipped) and what objects arn't visible..
96        // (None visible objects and object you introduce for the first time have always to be tested although the cheapest possible
97        // LOD (Level Of Detail) mesh and material wise).
98
99        /**
100          *   
101          * Remarks This function allows you to set how often the hardware occlusion really sent to the driver
102          * if you set it to 0 every hardware occlusion test is actually made. If you set it to 2 only 50% of your queries are sent.
103          * for all visible objects. 3 will result in 33% of all queries to actually be sent and so on.
104          * New and none visible objects will be tested all the time.
105          * This functionality is here because this class can keep track on visible and none visible objects for you.
106          * Once you you set the SkipRate for any hardware occlusion instance it effects all others.
107          */
108
109        void setSkipRate( int skip ) { mSkipInterval = skip; }          // Using 2 only 50 % of the tests are actually made and 3 results in only 33% of the tests. So on.
110        int      getSkipRate() { return mSkipInterval; }
111
112#ifdef GTP_VISIBILITY_MODIFIED_OGRE
113        bool pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag = HWOCCLUSIONQUERY_FLUSH );
114
115        static bool sUseArbQueries;
116#endif // GTP_VISIBILITY_MODIFIED_OGRE
117//----------------------------------------------------------------------
118// Protected members
119//--
120protected:
121
122        unsigned int    mPixelCount;
123        GLuint                  mQueryID;
124        bool                    m_bOcclusionQuery;
125        int                             mSkipCounter;
126        int                             mSkipInterval;
127        bool                    mHasOcclusionSupportNV;
128        bool                    mHasOcclusionSupportARB;
129};
130
131}
132
133#endif
134
Note: See TracBrowser for help on using the repository browser.