Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/shaders/src/orxonox/RenderQueueListener.cc @ 9419

Last change on this file since 9419 was 9419, checked in by davidsa, 12 years ago

Added documentation to orxonox::RenderQueueListener

File size: 3.2 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 *      Fabian 'x3n' Landau
24 *      Reto Grieder (physics)
25 *   Co-authors:
26 *      ...
27 *
28 */
29
30/**
31  @file RenderQueueListener.cc
32  @brief Definition of the RenderQueueListener class.
33*/
34
35#include "RenderQueueListener.h"
36
37#include <OgreRoot.h>
38#include <OgreRenderQueueListener.h>
39
40namespace orxonox
41{
42    /**
43    @brief
44    This function is called just before a RenderQueueGroup is rendered, this function is called by Ogre automatically with the correct parameters.
45
46    In this case we use it to set the stencil buffer parameters of the render system
47    */
48    void RenderQueueListener::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
49    {
50        if (queueGroupId == RENDER_QUEUE_STENCIL_OBJECTS)
51        { 
52            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
53
54            renderSystem->clearFrameBuffer(Ogre::FBT_STENCIL); 
55            renderSystem->setStencilCheckEnabled(true); 
56            renderSystem->setStencilBufferParams(Ogre::CMPF_ALWAYS_PASS,
57                STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
58                Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
59        } 
60        if (queueGroupId == RENDER_QUEUE_STENCIL_GLOW)
61        { 
62              Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
63              renderSystem->setStencilCheckEnabled(true); 
64              renderSystem->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL,
65                  STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
66                  Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
67        }
68    }
69   
70    /**
71    @brief
72        This function is called just after a RenderQueueGroup has been rendered, this function is called by Ogre automatically with the correct parameters.
73       
74        in this case we use it to unset the stencil buffer parameters, so the rest of the render queue is unaffected by it.
75    */
76    void RenderQueueListener::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
77    {
78        if (queueGroupId == RENDER_QUEUE_STENCIL_LAST) 
79        {
80            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
81            renderSystem->setStencilCheckEnabled(false); 
82            renderSystem->setStencilBufferParams(); 
83        }
84    }
85}
Note: See TracBrowser for help on using the repository browser.