renderTexTargetBinManager.h
Engine/source/renderInstance/renderTexTargetBinManager.h
Classes:
Public Typedefs
RenderTexTargetSize
Public Functions
Detailed Description
Public Typedefs
typedef RenderTexTargetBinManager::TargetSizeType RenderTexTargetSize
Public Functions
DefineEnumType(RenderTexTargetSize )
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#ifndef _TEXTARGETBIN_MGR_H_ 24#define _TEXTARGETBIN_MGR_H_ 25 26#ifndef _RENDERBINMANAGER_H_ 27#include "renderInstance/renderBinManager.h" 28#endif 29#ifndef _MATTEXTURETARGET_H_ 30#include "materials/matTextureTarget.h" 31#endif 32 33class ConditionerFeature; 34 35 36class RenderTexTargetBinManager : public RenderBinManager 37{ 38 typedef RenderBinManager Parent; 39 40public: 41 static const GFXFormat DefaultTargetFormat = GFXFormatR8G8B8A8; 42 static const U32 DefaultTargetChainLength = 1; 43 static const U32 DefaultTargetSize = 256; 44 45 enum TargetSizeType 46 { 47 WindowSize = 0, 48 WindowSizeScaled, 49 FixedSize 50 }; 51 52public: 53 54 RenderTexTargetBinManager( const RenderInstType &ritype = RenderPassManager::RIT_Mesh, 55 F32 renderOrder = 1.0f, 56 F32 processAddOrder = 1.0f, 57 const GFXFormat targetFormat = DefaultTargetFormat, 58 const Point2I &targetSize = Point2I(DefaultTargetSize, DefaultTargetSize), 59 const U32 targetChainLength = DefaultTargetChainLength); 60 61 virtual ~RenderTexTargetBinManager(); 62 63 virtual bool setTargetSize(const Point2I &newTargetSize); 64 65 virtual GFXTextureObject* getTargetTexture( U32 mrtIndex, S32 chainIndex = -1 ) const; 66 67 /// Force a target update 68 virtual bool updateTargets() { return _updateTargets(); } 69 70 void setTargetFormatConsole(const S32 &fmt) { setTargetFormat(GFXFormat(fmt)); } 71 virtual bool setTargetFormat(const GFXFormat &newTargetFormat); 72 73 S32 getTargetFormatConsole() { return getTargetFormat(); } 74 virtual const GFXFormat &getTargetFormat() const { return mTargetFormat; } 75 76 virtual void setTargetChainLength(const U32 chainLength); 77 virtual U32 getTargetChainLength() const { return mTargetChainLength; } 78 79 DECLARE_CONOBJECT(RenderTexTargetBinManager); 80 static void initPersistFields(); 81 virtual bool onAdd(); 82 83protected: 84 85 NamedTexTarget mNamedTarget; 86 87 GFXFormat mTargetFormat; 88 Point2I mTargetSize; 89 Point2F mTargetScale; 90 91 //RectI mTargetViewport; 92 TargetSizeType mTargetSizeType; 93 94 U32 mTargetChainLength; 95 U32 mTargetChainIdx; 96 U32 mNumRenderTargets; 97 GFXTextureTargetRef *mTargetChain; 98 GFXTexHandle **mTargetChainTextures; 99 100#ifndef TORQUE_SHIPPING 101 bool m_NeedsOnPostRender; 102#endif 103 bool mPreserve; 104 105 virtual bool _handleGFXEvent(GFXDevice::GFXDeviceEventType event); 106 virtual GFXTextureTargetRef _getTextureTarget(const U32 idx = 0); 107 108 /// Pushes the active render target, and sets itself as a render target. The 109 /// target is then cleared using 'mTargetClearColor', viewport is set properly, 110 /// and true is returned, and '_onPostRender' must be called after rendering 111 /// is complete. If the return value is false, than '_onPostRender' 112 /// should not be called. 113 /// 114 /// @param preserve If set to true, the contents of the current render target 115 // will be the same when _onPostRender is called. Otherwise 116 // the contents are undefined on console platforms. 117 virtual bool _onPreRender(SceneRenderState * state, bool preserve = false); 118 119 /// Resolves the active render target, pops the render target from _onPreRender, and sets debug info. 120 virtual void _onPostRender(); 121 122 virtual bool _updateTargets(); 123 124 virtual bool _setupTargets(); 125 126 virtual void _teardownTargets(); 127 128 /// The callback used to get texture events. 129 /// @see GFXTextureManager::addEventDelegate 130 void _onTextureEvent( GFXTexCallbackCode code ); 131}; 132 133typedef RenderTexTargetBinManager::TargetSizeType RenderTexTargetSize; 134DefineEnumType( RenderTexTargetSize ); 135 136#endif // _TEXTARGETBIN_MGR_H_ 137