| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #pragma once
- #include "BsGLPrerequisites.h"
- #include "BsGLTexture.h"
- #include "BsGLFrameBufferObject.h"
- #include "BsModule.h"
- // Extra GL constants
- #define GL_DEPTH24_STENCIL8_EXT 0x88F0
- namespace BansheeEngine
- {
- /** Base class for GL Render Textures
- */
- class BS_RSGL_EXPORT GLRenderTexture: public RenderTexture
- {
- public:
- virtual ~GLRenderTexture();
- bool requiresTextureFlipping() const { return true; }
- virtual void getCustomAttribute(const String& name, void* pData) const;
- protected:
- friend class GLTextureManager;
- GLRenderTexture();
- /**
- * @copydoc RenderTexture::initialize_internal().
- */
- void initialize_internal();
- /**
- * @copydoc RenderTexture::destroy_internal().
- */
- void destroy_internal();
- GLFrameBufferObject* mFB;
- };
- /**
- * @brief Manager/factory for RenderTextures.
- *
- * @note Must be initialized when RenderSystem is first started.
- */
- class BS_RSGL_EXPORT GLRTTManager : public Module<GLRTTManager>
- {
- public:
- GLRTTManager();
- ~GLRTTManager();
-
- /**
- * @brief Check if a certain format is usable as FBO rendertarget format.
- *
- * @note Thread safe.
- */
- bool checkFormat(PixelFormat format) { return mProps[format].valid; }
-
- /** Get a FBO without depth/stencil for temporary use, like blitting between textures.
- */
- GLuint getTemporaryFBO() { return mTempFBO; }
- /**
- * @brief Get the closest supported alternative format. If format is supported, returns format.
- *
- * @note Thread safe
- */
- virtual PixelFormat getSupportedAlternative(PixelFormat format);
- private:
- /** Frame Buffer Object properties for a certain texture format.
- */
- struct FormatProperties
- {
- bool valid; // This format can be used as RTT (FBO)
-
- /** Allowed modes/properties for this pixel format
- */
- struct Mode
- {
- UINT32 depth; // Depth format (0=no depth)
- UINT32 stencil; // Stencil format (0=no stencil)
- };
-
- Vector<Mode> modes;
- };
- /** Properties for all internal formats defined by the engine
- */
- FormatProperties mProps[PF_COUNT];
- /** Temporary FBO identifier
- */
- GLuint mTempFBO;
-
- /** Detect allowed FBO formats */
- void detectFBOFormats();
- GLuint _tryFormat(GLenum depthFormat, GLenum stencilFormat);
- bool _tryPackedFormat(GLenum packedFormat);
- };
- }
|