BsMultiRenderTexture.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsRenderTarget.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Descriptor class used for initializing a MultiRenderTexture.
  8. * Contains descriptors for each individual color render surface and
  9. * their common depth/stencil surface.
  10. */
  11. struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
  12. {
  13. Vector<RENDER_SURFACE_DESC> colorSurfaces;
  14. RENDER_SURFACE_DESC depthStencilSurface;
  15. };
  16. /**
  17. * @brief Contains various properties that describe a render texture.
  18. */
  19. class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
  20. {
  21. public:
  22. virtual ~MultiRenderTextureProperties() { }
  23. private:
  24. friend class MultiRenderTextureCore;
  25. friend class MultiRenderTexture;
  26. };
  27. /**
  28. * @brief Object representing multiple render textures. You may bind this to the pipeline
  29. * in order to render to all or some of the textures at once.
  30. *
  31. * @note Core thread only.
  32. */
  33. class BS_CORE_EXPORT MultiRenderTextureCore : public RenderTargetCore
  34. {
  35. public:
  36. virtual ~MultiRenderTextureCore();
  37. protected:
  38. MultiRenderTextureCore(MultiRenderTexture* parent, MultiRenderTextureProperties* properties, const MULTI_RENDER_TEXTURE_DESC& desc);
  39. /**
  40. * @copydoc RenderTargetCore::getNonCore
  41. */
  42. MultiRenderTexture* getNonCore() const;
  43. private:
  44. /**
  45. * @brief Checks that all render surfaces and depth/stencil surface match. If they do not match
  46. * an exception is thrown.
  47. */
  48. void throwIfBuffersDontMatch() const;
  49. // TODO - Not implemented
  50. virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
  51. protected:
  52. Vector<TextureViewPtr> mColorSurfaces;
  53. TextureViewPtr mDepthStencilSurface;
  54. };
  55. /**
  56. * @brief Object representing multiple render textures. You may bind this to the pipeline
  57. * in order to render to all or some of the textures at once.
  58. *
  59. * @note Sim thread only.
  60. */
  61. class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
  62. {
  63. public:
  64. virtual ~MultiRenderTexture() { }
  65. /**
  66. * @copydoc RenderTarget::initialize
  67. */
  68. void initialize(const MULTI_RENDER_TEXTURE_DESC& desc);
  69. /**
  70. * @copydoc RenderTexture::requiresTextureFlipping
  71. */
  72. virtual bool requiresTextureFlipping() const { return false; }
  73. /**
  74. * @brief Returns properties that describe the render texture.
  75. */
  76. const MultiRenderTextureProperties& getProperties() const;
  77. /**
  78. * @brief Retrieves a core implementation of a render texture usable only from the
  79. * core thread.
  80. *
  81. * @note Core thread only.
  82. */
  83. MultiRenderTextureCore* getCore() const;
  84. /**
  85. * @copydoc TextureManager::createMultiRenderTexture
  86. */
  87. static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
  88. protected:
  89. MultiRenderTexture() { }
  90. /**
  91. * @copydoc RenderTexture::createCore
  92. */
  93. virtual RenderTargetCore* createCore();
  94. /**
  95. * @brief Creates a core implementation of a render texture. This implementation
  96. * is to be used on the core thread only.
  97. */
  98. virtual MultiRenderTextureCore* createCore(MultiRenderTextureProperties* properties, const MULTI_RENDER_TEXTURE_DESC& desc) = 0;
  99. MULTI_RENDER_TEXTURE_DESC mDesc;
  100. };
  101. }