gfxGLTextureTarget.h
Engine/source/gfx/gl/gfxGLTextureTarget.h
Classes:
class
Render to texture support for OpenGL.
Detailed Description
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 _GFXGLTEXTURETARGET_H_ 25#define _GFXGLTEXTURETARGET_H_ 26 27#include "gfx/gfxTarget.h" 28#include "core/util/autoPtr.h" 29 30class GFXGLTextureObject; 31class _GFXGLTargetDesc; 32class _GFXGLTextureTargetImpl; 33 34/// Render to texture support for OpenGL. 35/// This class needs to make a number of assumptions due to the requirements 36/// and complexity of render to texture in OpenGL. 37/// 1) This class is only guaranteed to work with 2D textures or cubemaps. 3D textures 38/// may or may not work. 39/// 2) This class does not currently support multiple texture targets. Regardless 40/// of how many targets you bind, only Color0 will be used. 41/// 3) This class requires that the DepthStencil and Color0 targets have identical 42/// dimensions. 43/// 4) If the DepthStencil target is GFXTextureTarget::sDefaultStencil, then the 44/// Color0 target should be the same size as the current backbuffer and should also 45/// be the same format (typically R8G8B8A8) 46class GFXGLTextureTarget : public GFXTextureTarget 47{ 48public: 49 GFXGLTextureTarget(bool genMips); 50 virtual ~GFXGLTextureTarget(); 51 52 virtual const Point2I getSize(); 53 virtual GFXFormat getFormat(); 54 virtual void attachTexture(RenderSlot slot, GFXTextureObject *tex, U32 mipLevel=0, U32 zOffset = 0); 55 virtual void attachTexture(RenderSlot slot, GFXCubemap *tex, U32 face, U32 mipLevel=0); 56 virtual void clearAttachments(); 57 58 /// Functions to query internal state 59 /// @{ 60 61 /// Returns the internal structure for the given slot. This should only be called by our internal implementations. 62 _GFXGLTargetDesc* getTargetDesc(RenderSlot slot) const; 63 64 /// @} 65 66 void deactivate(); 67 void zombify(); 68 void resurrect(); 69 virtual const String describeSelf() const; 70 71 virtual void resolve(); 72 73 virtual void resolveTo(GFXTextureObject* obj); 74 75protected: 76 77 friend class GFXGLDevice; 78 79 /// The callback used to get texture events. 80 /// @see GFXTextureManager::addEventDelegate 81 void _onTextureEvent( GFXTexCallbackCode code ); 82 83 /// Pointer to our internal implementation 84 AutoPtr<_GFXGLTextureTargetImpl> _impl; 85 86 /// Array of _GFXGLTargetDesc's, an internal struct used to keep track of texture data. 87 AutoPtr<_GFXGLTargetDesc> mTargets[MaxRenderSlotId]; 88 89 /// These redirect to our internal implementation 90 /// @{ 91 92 void applyState(); 93 void makeActive(); 94 95 /// @} 96 97 //copy FBO 98 GLuint mCopyFboSrc, mCopyFboDst; 99 100}; 101 102#endif 103