1 | /* |
---|
2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
3 | * > www.orxonox.net < |
---|
4 | * |
---|
5 | * |
---|
6 | * License notice: |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
21 | * |
---|
22 | * Author: |
---|
23 | * Fabian 'x3n' Landau |
---|
24 | * Reto Grieder (physics) |
---|
25 | * Co-authors: |
---|
26 | * ... |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | /** |
---|
31 | @file RenderQueueListener.h |
---|
32 | @brief Definition of the RenderQueueListener class. |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _ORenderQueueListener_H__ |
---|
36 | #define _ORenderQueueListener_H__ |
---|
37 | |
---|
38 | #include "OrxonoxPrereqs.h" |
---|
39 | |
---|
40 | #include <OgreRenderQueueListener.h> |
---|
41 | #include <OgreHardwareOcclusionQuery.h> |
---|
42 | |
---|
43 | namespace orxonox |
---|
44 | { |
---|
45 | enum RenderQueueGroupID //!< these are IDs for render queues that are executed just after the main render queue defined by Ogre, we need more than one for Stencil Glow |
---|
46 | { |
---|
47 | RENDER_QUEUE_MAIN = Ogre::RENDER_QUEUE_MAIN, //reference to the main render queue |
---|
48 | RENDER_QUEUE_STENCIL_OBJECTS = RENDER_QUEUE_MAIN+1, |
---|
49 | RENDER_QUEUE_STENCIL_GLOW = RENDER_QUEUE_MAIN+2, |
---|
50 | RENDER_QUEUE_STENCIL_LAST = RENDER_QUEUE_STENCIL_GLOW, //this is a reference to the last render queue to be affected by stencil glow effects |
---|
51 | RENDER_QUEUE_HOQ = RENDER_QUEUE_STENCIL_LAST+1 //this is where we render the objects for occlusion queries (use transparent material) |
---|
52 | }; |
---|
53 | |
---|
54 | const int STENCIL_VALUE_FOR_GLOW = 1; //!< this is a reference value for our mask, |
---|
55 | //!< if more than one type of stencil mask is to be used, each of them need their own value |
---|
56 | const int STENCIL_FULL_MASK = 0xFFFFFFFF; //!< this is a reference mask used in our stencil buffer |
---|
57 | |
---|
58 | /** |
---|
59 | @brief |
---|
60 | This class derives from the Ogre-Class RenderQueueListener and provides a way to define new rendering stages to enable use of e.g. stencil buffers |
---|
61 | to increase the number of shader effects we can create. Especially important for shader-based alpha blending. |
---|
62 | |
---|
63 | @author |
---|
64 | David 'davidsa' Salvisberg |
---|
65 | */ |
---|
66 | class _OrxonoxExport RenderQueueListener : public Ogre::RenderQueueListener |
---|
67 | { |
---|
68 | public: |
---|
69 | RenderQueueListener(); |
---|
70 | ~RenderQueueListener(); |
---|
71 | |
---|
72 | /** |
---|
73 | @brief |
---|
74 | This function is returning the current pixel count and resets the pixel state if we're ready to do another Hardware Occlusion Query |
---|
75 | |
---|
76 | @return |
---|
77 | current pixel count taken from the last Hardware Occlusion Query |
---|
78 | */ |
---|
79 | unsigned int getPixelCount(); |
---|
80 | |
---|
81 | /** |
---|
82 | @brief |
---|
83 | This function is called just before a RenderQueueGroup is rendered, this function is called by Ogre automatically with the correct parameters. |
---|
84 | |
---|
85 | In this case we use it to set the stencil buffer parameters of the render system |
---|
86 | */ |
---|
87 | virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation); |
---|
88 | /** |
---|
89 | @brief |
---|
90 | This function is called just after a RenderQueueGroup has been rendered, this function is called by Ogre automatically with the correct parameters. |
---|
91 | |
---|
92 | in this case we use it to unset the stencil buffer parameters, so the rest of the render queue is unaffected by it. |
---|
93 | */ |
---|
94 | virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation); |
---|
95 | |
---|
96 | private: |
---|
97 | Ogre::HardwareOcclusionQuery* hardwareOcclusionQuery_; //!< this stores the current instance of the HOQ used in the render system |
---|
98 | unsigned int pixelCount_; //!< this stores the last pixel count returned by the last HOQ in the corresponding render group |
---|
99 | |
---|
100 | enum PixelState //!< enum to distinguish the several HOQ pixel count states |
---|
101 | { |
---|
102 | READY_FOR_RENDER, |
---|
103 | QUERY_STARTED, |
---|
104 | READY_FOR_ACCESS |
---|
105 | }; |
---|
106 | |
---|
107 | PixelState pixelState_; //!< this stores the current state of the Hardware Occlusion Query |
---|
108 | }; |
---|
109 | } |
---|
110 | |
---|
111 | #endif /* _ORenderQueueListener_H__ */ |
---|