OgreCompositorManager.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __CompositorManager_H__
#define __CompositorManager_H__
#include "OgrePrerequisites.h"
#include "OgreResourceManager.h"
#include "OgreCompositor.h"
#include "OgreRectangle2D.h"
#include "OgreRenderSystem.h"
#include "OgreCompositionTechnique.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport CompositorManager : public ResourceManager, public Singleton<CompositorManager>
{
public:
CompositorManager();
virtual ~CompositorManager();
Resource* createImpl(const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader,
const NameValuePairList* params);
void initialise(void);
CompositorPtr create (const String& name, const String& group,
bool isManual = false, ManualResourceLoader* loader = 0,
const NameValuePairList* createParams = 0);
CompositorPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
void parseScript(DataStreamPtr& stream, const String& groupName);
CompositorChain *getCompositorChain(Viewport *vp);
bool hasCompositorChain(Viewport *vp) const;
void removeCompositorChain(Viewport *vp);
CompositorInstance *addCompositor(Viewport *vp, const String &compositor, int addPosition=-1);
void removeCompositor(Viewport *vp, const String &compositor);
void setCompositorEnabled(Viewport *vp, const String &compositor, bool value);
Renderable *_getTexturedRectangle2D();
void removeAll(void);
void _reconstructAllCompositorResources();
typedef set<Texture*>::type UniqueTextureSet;
TexturePtr getPooledTexture(const String& name, const String& localName,
size_t w, size_t h,
PixelFormat f, uint aa, const String& aaHint, bool srgb, UniqueTextureSet& texturesAlreadyAssigned,
CompositorInstance* inst, CompositionTechnique::TextureScope scope);
void freePooledTextures(bool onlyIfUnreferenced = true);
void registerCompositorLogic(const String& name, CompositorLogic* logic);
void unregisterCompositorLogic(const String& name);
CompositorLogic* getCompositorLogic(const String& name);
void registerCustomCompositionPass(const String& name, CustomCompositionPass* customPass);
CustomCompositionPass* getCustomCompositionPass(const String& name);
static CompositorManager& getSingleton(void);
static CompositorManager* getSingletonPtr(void);
private:
typedef map<Viewport*, CompositorChain*>::type Chains;
Chains mChains;
void freeChains();
Rectangle2D *mRectangle;
typedef vector<CompositorInstance *>::type Instances;
Instances mInstances;
typedef map<String, CompositorLogic*>::type CompositorLogicMap;
CompositorLogicMap mCompositorLogics;
typedef map<String, CustomCompositionPass*>::type CustomCompositionPassMap;
CustomCompositionPassMap mCustomCompositionPasses;
typedef vector<TexturePtr>::type TextureList;
typedef VectorIterator<TextureList> TextureIterator;
struct TextureDef
{
size_t width, height;
PixelFormat format;
uint fsaa;
String fsaaHint;
bool sRGBwrite;
TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String& aaHint, bool srgb)
: width(w), height(h), format(f), fsaa(aa), fsaaHint(aaHint), sRGBwrite(srgb)
{
}
};
struct TextureDefLess
{
bool _OgreExport operator()(const TextureDef& x, const TextureDef& y) const
{
if (x.format < y.format)
return true;
else if (x.format == y.format)
{
if (x.width < y.width)
return true;
else if (x.width == y.width)
{
if (x.height < y.height)
return true;
else if (x.height == y.height)
{
if (x.fsaa < y.fsaa)
return true;
else if (x.fsaa == y.fsaa)
{
if (x.fsaaHint < y.fsaaHint)
return true;
else if (x.fsaaHint == y.fsaaHint)
{
if (!x.sRGBwrite && y.sRGBwrite)
return true;
}
}
}
}
}
return false;
}
virtual ~TextureDefLess() {}
};
typedef map<TextureDef, TextureList*, TextureDefLess>::type TexturesByDef;
TexturesByDef mTexturesByDef;
typedef std::pair<String, String> StringPair;
typedef map<TextureDef, TexturePtr, TextureDefLess>::type TextureDefMap;
typedef map<StringPair, TextureDefMap>::type ChainTexturesByDef;
ChainTexturesByDef mChainTexturesByDef;
bool isInputPreviousTarget(CompositorInstance* inst, const Ogre::String& localName);
bool isInputPreviousTarget(CompositorInstance* inst, TexturePtr tex);
bool isInputToOutputTarget(CompositorInstance* inst, const Ogre::String& localName);
bool isInputToOutputTarget(CompositorInstance* inst, TexturePtr tex);
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::CompositorManager::Chains
map< Viewport *, CompositorChain * >::type Chains
Definition: OgreCompositorManager.h:211
OgreRectangle2D.h
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::CompositorManager::TextureDefLess
Definition: OgreCompositorManager.h:249
Ogre::CompositorManager::TextureDefLess::operator()
bool _OgreExport operator()(const TextureDef &x, const TextureDef &y) const
Definition: OgreCompositorManager.h:251
Ogre::CompositorManager::TextureDef::TextureDef
TextureDef(size_t w, size_t h, PixelFormat f, uint aa, const String &aaHint, bool srgb)
Definition: OgreCompositorManager.h:243
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::CompositorManager::TextureDef::width
size_t width
Definition: OgreCompositorManager.h:237
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::set::type
std::set< T, P, A > type
Definition: OgrePrerequisites.h:522
Ogre::CompositorManager::TextureDef::height
size_t height
Definition: OgreCompositorManager.h:237
Ogre::CompositorLogic
Interface for compositor logics, which can be automatically binded to compositors, allowing per-compositor logic (such as attaching a relevant listener) to happen automatically.
Definition: OgreCompositorLogic.h:46
Ogre::CompositorInstance
An instance of a Compositor object for one Viewport.
Definition: OgreCompositorInstance.h:50
Ogre::CompositionTechnique::TextureScope
TextureScope
Definition: OgreCompositionTechnique.h:52
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Definition: OgreResourceGroupManager.h:270
Ogre::CompositorManager::mCompositorLogics
CompositorLogicMap mCompositorLogics
Definition: OgreCompositorManager.h:226
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::Resource
Abstract class representing a loadable resource (e.g.
Definition: OgreResource.h:79
Ogre::CompositorManager::TextureDef::sRGBwrite
bool sRGBwrite
Definition: OgreCompositorManager.h:241
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::CompositorManager::TextureDefMap
map< TextureDef, TexturePtr, TextureDefLess >::type TextureDefMap
Definition: OgreCompositorManager.h:289
Ogre::Viewport
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
Ogre::CompositorManager::CompositorLogicMap
map< String, CompositorLogic * >::type CompositorLogicMap
Map of registered compositor logics.
Definition: OgreCompositorManager.h:225
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::CompositorManager::mTexturesByDef
TexturesByDef mTexturesByDef
Definition: OgreCompositorManager.h:286
Ogre::CompositorManager
Class for managing Compositor settings for Ogre.
Definition: OgreCompositorManager.h:59
OgreCompositionTechnique.h
OgrePrerequisites.h
Ogre::map::type
std::map< K, V, P, A > type
Definition: OgrePrerequisites.h:536
Ogre::CompositorManager::StringPair
std::pair< String, String > StringPair
Definition: OgreCompositorManager.h:288
Ogre::CompositorManager::mChains
Chains mChains
Definition: OgreCompositorManager.h:212
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
OgreRenderSystem.h
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
OgreResourceManager.h
Ogre::CompositorManager::TexturesByDef
map< TextureDef, TextureList *, TextureDefLess >::type TexturesByDef
Definition: OgreCompositorManager.h:285
Ogre::CompositorManager::TextureDef::format
PixelFormat format
Definition: OgreCompositorManager.h:238
Ogre::CompositorChain
Chain of compositor effects applying to one viewport.
Definition: OgreCompositorChain.h:48
OgreHeaderSuffix.h
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::CompositorManager::TextureDefLess::~TextureDefLess
virtual ~TextureDefLess()
Definition: OgreCompositorManager.h:283
Ogre::Rectangle2D
Allows the rendering of a simple 2D rectangle This class renders a simple 2D rectangle; this rectangl...
Definition: OgreRectangle2D.h:49
Ogre::CustomCompositionPass
Interface for custom composition passes, allowing custom operations (in addition to the quad...
Definition: OgreCustomCompositionPass.h:45
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::CompositorManager::mInstances
Instances mInstances
Definition: OgreCompositorManager.h:222
Ogre::CompositorManager::CustomCompositionPassMap
map< String, CustomCompositionPass * >::type CustomCompositionPassMap
Map of registered custom composition passes.
Definition: OgreCompositorManager.h:229
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgrePrerequisites.h:310
Ogre::CompositorManager::TextureDef::fsaa
uint fsaa
Definition: OgreCompositorManager.h:239
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::CompositorManager::mChainTexturesByDef
ChainTexturesByDef mChainTexturesByDef
Definition: OgreCompositorManager.h:292
Ogre::CompositorManager::TextureDef
Definition: OgreCompositorManager.h:235
OgreHeaderPrefix.h
Ogre::CompositorManager::Instances
vector< CompositorInstance * >::type Instances
List of instances.
Definition: OgreCompositorManager.h:221
Ogre::Singleton
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::CompositorManager::mCustomCompositionPasses
CustomCompositionPassMap mCustomCompositionPasses
Definition: OgreCompositorManager.h:230
Ogre::CompositorManager::ChainTexturesByDef
map< StringPair, TextureDefMap >::type ChainTexturesByDef
Definition: OgreCompositorManager.h:290
Ogre::CompositorManager::TextureDef::fsaaHint
String fsaaHint
Definition: OgreCompositorManager.h:240
OgreCompositor.h
Ogre::CompositorManager::UniqueTextureSet
set< Texture * >::type UniqueTextureSet
Definition: OgreCompositorManager.h:136
Ogre::CompositorManager::TextureIterator
VectorIterator< TextureList > TextureIterator
Definition: OgreCompositorManager.h:233
Ogre::CompositorManager::TextureList
vector< TexturePtr >::type TextureList
Definition: OgreCompositorManager.h:232
Ogre::CompositorManager::mRectangle
Rectangle2D * mRectangle
Definition: OgreCompositorManager.h:218

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.