[9407] | 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: |
---|
[11075] | 23 | * David 'davidsa' Salvisberg |
---|
[9407] | 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[9419] | 29 | /** |
---|
| 30 | @file RenderQueueListener.h |
---|
| 31 | @brief Definition of the RenderQueueListener class. |
---|
| 32 | */ |
---|
| 33 | |
---|
[9407] | 34 | #ifndef _ORenderQueueListener_H__ |
---|
| 35 | #define _ORenderQueueListener_H__ |
---|
| 36 | |
---|
| 37 | #include "OrxonoxPrereqs.h" |
---|
| 38 | |
---|
| 39 | #include <OgreRenderQueueListener.h> |
---|
[9448] | 40 | #include <OgreHardwareOcclusionQuery.h> |
---|
[9407] | 41 | |
---|
| 42 | namespace orxonox |
---|
| 43 | { |
---|
[9419] | 44 | 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 |
---|
[9407] | 45 | { |
---|
[9419] | 46 | RENDER_QUEUE_MAIN = Ogre::RENDER_QUEUE_MAIN, //reference to the main render queue |
---|
[9407] | 47 | RENDER_QUEUE_STENCIL_OBJECTS = RENDER_QUEUE_MAIN+1, |
---|
| 48 | RENDER_QUEUE_STENCIL_GLOW = RENDER_QUEUE_MAIN+2, |
---|
[9448] | 49 | RENDER_QUEUE_STENCIL_LAST = RENDER_QUEUE_STENCIL_GLOW, //this is a reference to the last render queue to be affected by stencil glow effects |
---|
| 50 | RENDER_QUEUE_HOQ = RENDER_QUEUE_STENCIL_LAST+1 //this is where we render the objects for occlusion queries (use transparent material) |
---|
[9407] | 51 | }; |
---|
| 52 | |
---|
[11075] | 53 | constexpr int STENCIL_VALUE_FOR_GLOW = 1; //!< this is a reference value for our mask, |
---|
[9419] | 54 | //!< if more than one type of stencil mask is to be used, each of them need their own value |
---|
[11075] | 55 | constexpr int STENCIL_FULL_MASK = 0xFFFFFFFF; //!< this is a reference mask used in our stencil buffer |
---|
[9407] | 56 | |
---|
[9419] | 57 | /** |
---|
| 58 | @brief |
---|
| 59 | 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 |
---|
| 60 | to increase the number of shader effects we can create. Especially important for shader-based alpha blending. |
---|
| 61 | |
---|
| 62 | @author |
---|
| 63 | David 'davidsa' Salvisberg |
---|
| 64 | */ |
---|
[9407] | 65 | class _OrxonoxExport RenderQueueListener : public Ogre::RenderQueueListener |
---|
| 66 | { |
---|
| 67 | public: |
---|
[9448] | 68 | RenderQueueListener(); |
---|
| 69 | ~RenderQueueListener(); |
---|
| 70 | |
---|
[9419] | 71 | /** |
---|
| 72 | @brief |
---|
[9448] | 73 | This function is returning the current pixel count and resets the pixel state if we're ready to do another Hardware Occlusion Query |
---|
| 74 | |
---|
| 75 | @return |
---|
| 76 | current pixel count taken from the last Hardware Occlusion Query |
---|
| 77 | */ |
---|
| 78 | unsigned int getPixelCount(); |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | @brief |
---|
[9419] | 82 | This function is called just before a RenderQueueGroup is rendered, this function is called by Ogre automatically with the correct parameters. |
---|
| 83 | |
---|
| 84 | In this case we use it to set the stencil buffer parameters of the render system |
---|
| 85 | */ |
---|
[11075] | 86 | virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation) override; |
---|
[9419] | 87 | /** |
---|
| 88 | @brief |
---|
| 89 | This function is called just after a RenderQueueGroup has been rendered, this function is called by Ogre automatically with the correct parameters. |
---|
| 90 | |
---|
| 91 | in this case we use it to unset the stencil buffer parameters, so the rest of the render queue is unaffected by it. |
---|
| 92 | */ |
---|
[11075] | 93 | virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation) override; |
---|
[9448] | 94 | |
---|
| 95 | private: |
---|
| 96 | Ogre::HardwareOcclusionQuery* hardwareOcclusionQuery_; //!< this stores the current instance of the HOQ used in the render system |
---|
| 97 | unsigned int pixelCount_; //!< this stores the last pixel count returned by the last HOQ in the corresponding render group |
---|
| 98 | |
---|
[11075] | 99 | enum class PixelState //!< enum to distinguish the several HOQ pixel count states |
---|
[9448] | 100 | { |
---|
| 101 | READY_FOR_RENDER, |
---|
| 102 | QUERY_STARTED, |
---|
| 103 | READY_FOR_ACCESS |
---|
| 104 | }; |
---|
| 105 | |
---|
| 106 | PixelState pixelState_; //!< this stores the current state of the Hardware Occlusion Query |
---|
[9407] | 107 | }; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | #endif /* _ORenderQueueListener_H__ */ |
---|