small fix

This commit is contained in:
scrawl 2012-04-29 03:38:00 +02:00
parent 11ebae3be2
commit 9cf6f27f96
3 changed files with 102 additions and 2 deletions

View file

@ -0,0 +1,49 @@
#include "compositors.hpp"
#include <OgreViewport.h>
#include <OgreCompositorManager.h>
using namespace MWRender;
Compositors::Compositors(Ogre::Viewport* vp) :
mViewport(vp)
, mEnabled(true)
{
}
Compositors::~Compositors()
{
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
}
void Compositors::setEnabled (const bool enabled)
{
for (CompositorMap::iterator it=mCompositors.begin();
it != mCompositors.end(); ++it)
{
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, it->first, enabled && it->second.first);
}
mEnabled = enabled;
}
void Compositors::addCompositor (const std::string& name, const int priority)
{
int id = 0;
for (CompositorMap::iterator it=mCompositors.begin();
it != mCompositors.end(); ++it)
{
if (it->second.second > priority)
break;
++id;
}
Ogre::CompositorManager::getSingleton().addCompositor (mViewport, name, id);
mCompositors[name] = std::make_pair(false, priority);
}
void Compositors::setCompositorEnabled (const std::string& name, const bool enabled)
{
mCompositors[name].first = enabled;
Ogre::CompositorManager::getSingleton().setCompositorEnabled (mViewport, name, enabled && mEnabled);
}

View file

@ -0,0 +1,53 @@
#ifndef GAME_MWRENDER_COMPOSITORS_H
#define GAME_MWRENDER_COMPOSITORS_H
#include <map>
#include <string>
namespace Ogre
{
class Viewport;
}
namespace MWRender
{
typedef std::map < std::string, std::pair<bool, int> > CompositorMap;
/// \brief Manages a set of compositors for one viewport
class Compositors
{
public:
Compositors(Ogre::Viewport* vp);
virtual ~Compositors();
/**
* enable or disable all compositors globally
*/
void setEnabled (const bool enabled);
bool toggle() { setEnabled(!mEnabled); return mEnabled; }
/**
* enable or disable a specific compositor
* @note enable has no effect if all compositors are globally disabled
*/
void setCompositorEnabled (const std::string& name, const bool enabled);
/**
* @param name of compositor
* @param priority, lower number will be first in the chain
*/
void addCompositor (const std::string& name, const int priority);
protected:
/// maps compositor name to its "enabled" state
CompositorMap mCompositors;
bool mEnabled;
Ogre::Viewport* mViewport;
};
}
#endif

View file

@ -159,8 +159,6 @@ class RenderingManager: private RenderingInterface {
bool mSunEnabled;
bool mCompositorsEnabled;
SkyManager* mSkyManager;
OcclusionQuery* mOcclusionQuery;