Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/RenderQueueListener.h @ 11359

Last change on this file since 11359 was 11080, checked in by landauf, 4 years ago

merged shaders back to trunk (pps project from HS 2012)

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
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 *      David 'davidsa' Salvisberg
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30  @file RenderQueueListener.h
31  @brief Definition of the RenderQueueListener class.
32*/
33
34#ifndef _ORenderQueueListener_H__
35#define _ORenderQueueListener_H__
36
37#include "OrxonoxPrereqs.h"
38
39#include <OgreRenderQueueListener.h>
40#include <OgreHardwareOcclusionQuery.h>
41
42namespace orxonox
43{
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
45    {
46        RENDER_QUEUE_MAIN = Ogre::RENDER_QUEUE_MAIN, //reference to the main render queue
47        RENDER_QUEUE_STENCIL_OBJECTS = RENDER_QUEUE_MAIN+1,
48        RENDER_QUEUE_STENCIL_GLOW = RENDER_QUEUE_MAIN+2,
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)
51    };
52
53    constexpr int STENCIL_VALUE_FOR_GLOW = 1; //!< this is a reference value for our mask,
54                                          //!< if more than one type of stencil mask is to be used, each of them need their own value
55    constexpr int STENCIL_FULL_MASK = 0xFFFFFFFF; //!< this is a reference mask used in our stencil buffer
56   
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    */
65    class _OrxonoxExport RenderQueueListener : public Ogre::RenderQueueListener
66    {
67        public:
68            RenderQueueListener();
69            ~RenderQueueListener();
70   
71            /**
72            @brief
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
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            */
86            virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation) override;
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            */
93            virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation) override;
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           
99            enum class PixelState //!< enum to distinguish the several HOQ pixel count states
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
107    };
108}
109
110#endif /* _ORenderQueueListener_H__ */
Note: See TracBrowser for help on using the repository browser.