Torque3D Documentation / _generateds / postEffectManager.h

postEffectManager.h

Engine/source/postFx/postEffectManager.h

More...

Classes:

Public Defines

define
PFXMGR() <>::instance()

Returns the PostEffectManager singleton.

Detailed Description

Public Defines

PFXMGR() <>::instance()

Returns the PostEffectManager singleton.

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _POSTEFFECTMANAGER_H_
 25#define _POSTEFFECTMANAGER_H_
 26
 27#ifndef _GFXDEVICE_H_
 28#include "gfx/gfxDevice.h"
 29#endif
 30#ifndef _TVECTOR_H_
 31#include "core/util/tVector.h"
 32#endif
 33#ifndef _TDICTIONARY_H_
 34#include "core/util/tDictionary.h"
 35#endif
 36#ifndef _TSINGLETON_H_
 37#include "core/util/tSingleton.h"
 38#endif
 39#ifndef _POSTEFFECTCOMMON_H_
 40#include "postFx/postEffectCommon.h"
 41#endif
 42
 43class PostEffect;
 44class RenderBinManager;
 45class SceneRenderState;
 46class SceneManager;
 47
 48
 49class PostEffectManager
 50{
 51protected:
 52
 53   friend class PostEffect;
 54
 55   typedef Vector<PostEffect*> EffectVector;
 56
 57   typedef Map<String,EffectVector> EffectMap;
 58
 59   /// A global flag for toggling the post effect system.  It
 60   /// is tied to the $pref::enablePostEffects preference.
 61   static bool smRenderEffects;
 62
 63   EffectVector mEndOfFrameList;
 64   EffectVector mAfterDiffuseList;
 65   EffectMap mAfterBinMap;
 66   EffectMap mBeforeBinMap;
 67
 68   /// A copy of the last requested back buffer.
 69   GFXTexHandle mBackBufferCopyTex;
 70
 71   //GFXTexHandle mBackBufferFloatCopyTex;
 72
 73   /// The target at the time the last back buffer
 74   /// was copied.  Used to detect the need to recopy.
 75   GFXTarget *mLastBackBufferTarget;
 76
 77   // State for current frame and last frame
 78   bool mFrameStateSwitch;
 79
 80   PFXFrameState mFrameState[2];
 81
 82   bool _handleDeviceEvent( GFXDevice::GFXDeviceEventType evt );
 83
 84   void _handleBinEvent(   RenderBinManager *bin,                           
 85                           const SceneRenderState* sceneState,
 86                           bool isBinStart );  
 87
 88   ///
 89   void _onPostRenderPass( SceneManager *sceneGraph, const SceneRenderState *sceneState );
 90
 91   // Helper method
 92   void _updateResources();
 93
 94   ///
 95   static S32 _effectPrioritySort( PostEffect* const*e1, PostEffect* const*e2 );
 96
 97   bool _addEffect( PostEffect *effect );
 98
 99   bool _removeEffect( PostEffect *effect );
100
101public:
102
103   PostEffectManager();
104
105   virtual ~PostEffectManager();
106
107   void renderEffects(  const SceneRenderState *state,
108                        const PFXRenderTime effectTiming, 
109                        const String &binName = String::EmptyString );
110
111   /// Returns the current back buffer texture taking
112   /// a copy of if the target has changed or the buffer
113   /// was previously released.
114   GFXTextureObject* getBackBufferTex();
115   
116   /// Releases the current back buffer so that a
117   /// new copy is made on the next request.
118   void releaseBackBufferTex();
119
120   /*
121   bool submitEffect( PostEffect *effect, const PFXRenderTime renderTime = PFXDefaultRenderTime, const GFXRenderBinTypes afterBin = GFXBin_DefaultPostProcessBin )
122   {
123      return _addEntry( effect, false, renderTime, afterBin );
124   }
125   */
126   
127   // State interface
128   const PFXFrameState &getFrameState() const { return mFrameState[mFrameStateSwitch]; }
129   const PFXFrameState &getLastFrameState() const { return mFrameState[!mFrameStateSwitch]; }
130
131   void setFrameState(const PFXFrameState& newState) { mFrameState[mFrameStateSwitch] = newState; }
132   void setFrameMatrices( const MatrixF &worldToCamera, const MatrixF &cameraToScreen );
133   
134   // For ManagedSingleton.
135   static const char* getSingletonName() { return "PostEffectManager"; }
136
137   void dumpActivePostFX();
138};
139
140/// Returns the PostEffectManager singleton.
141#define PFXMGR ManagedSingleton<PostEffectManager>::instance()
142
143#endif // _POSTEFFECTMANAGER_H_
144