Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox::RenderQueueListener: Implemented a rudimentary RenderQueueListener to enable the use of stencil buffer for elaborate alpha blending shaders without creating artifacts from overlapping faces. Also added a XML Port to assign a Model to a certain RenderQueueGroup. Needs to be improved to allow the use of strings for choosing the group instead of a static int which may change in the feature.

File size: 2.6 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#include "RenderQueueListener.h"
31
32#include <OgreRoot.h>
33#include <OgreRenderQueueListener.h>
34
35namespace orxonox
36{
37    void RenderQueueListener::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
38    {
39        if (queueGroupId == RENDER_QUEUE_STENCIL_OBJECTS)
40        { 
41            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
42
43            renderSystem->clearFrameBuffer(Ogre::FBT_STENCIL); 
44            renderSystem->setStencilCheckEnabled(true); 
45            renderSystem->setStencilBufferParams(Ogre::CMPF_ALWAYS_PASS,
46                STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
47                Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
48        } 
49        if (queueGroupId == RENDER_QUEUE_STENCIL_GLOW)
50        { 
51              Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
52              renderSystem->setStencilCheckEnabled(true); 
53              renderSystem->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL,
54                  STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 
55                  Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
56        }
57    }
58   
59    void RenderQueueListener::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation)
60    {
61        if (queueGroupId == RENDER_QUEUE_STENCIL_LAST) 
62        {
63            Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 
64            renderSystem->setStencilCheckEnabled(false); 
65            renderSystem->setStencilBufferParams(); 
66        }
67    }
68}
Note: See TracBrowser for help on using the repository browser.