BsMultiRenderTexture.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. protected:
  24. friend class MultiRenderTextureCore;
  25. friend class MultiRenderTexture;
  26. /**
  27. * @copydoc RenderTargetProperties::copyToBuffer
  28. */
  29. virtual void copyToBuffer(UINT8* buffer) const;
  30. /**
  31. * @copydoc RenderTargetProperties::copyFromBuffer
  32. */
  33. virtual void copyFromBuffer(UINT8* buffer);
  34. /**
  35. * @copydoc RenderTargetProperties::getSize
  36. */
  37. virtual UINT32 getSize() const;
  38. };
  39. /**
  40. * @brief Object representing multiple render textures. You may bind this to the pipeline
  41. * in order to render to all or some of the textures at once.
  42. *
  43. * @note Core thread only.
  44. */
  45. class BS_CORE_EXPORT MultiRenderTextureCore : public RenderTargetCore
  46. {
  47. public:
  48. virtual ~MultiRenderTextureCore();
  49. protected:
  50. MultiRenderTextureCore(MultiRenderTexture* parent, MultiRenderTextureProperties* properties, const MULTI_RENDER_TEXTURE_DESC& desc);
  51. /**
  52. * @copydoc RenderTargetCore::getNonCore
  53. */
  54. MultiRenderTexture* getNonCore() const;
  55. /**
  56. * @copydoc CoreObjectCore::initialize
  57. */
  58. virtual void initialize();
  59. /**
  60. * @copydoc CoreObjectCore::destroy
  61. */
  62. virtual void destroy();
  63. private:
  64. /**
  65. * @brief Checks that all render surfaces and depth/stencil surface match. If they do not match
  66. * an exception is thrown.
  67. */
  68. void throwIfBuffersDontMatch() const;
  69. // TODO - Not implemented
  70. virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
  71. protected:
  72. Vector<TextureViewPtr> mColorSurfaces;
  73. TextureViewPtr mDepthStencilSurface;
  74. MULTI_RENDER_TEXTURE_DESC mDesc;
  75. };
  76. /**
  77. * @brief Object representing multiple render textures. You may bind this to the pipeline
  78. * in order to render to all or some of the textures at once.
  79. *
  80. * @note Sim thread only.
  81. */
  82. class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
  83. {
  84. public:
  85. virtual ~MultiRenderTexture() { }
  86. /**
  87. * @copydoc RenderTarget::initialize
  88. */
  89. void initialize(const MULTI_RENDER_TEXTURE_DESC& desc);
  90. /**
  91. * @copydoc RenderTexture::requiresTextureFlipping
  92. */
  93. virtual bool requiresTextureFlipping() const { return false; }
  94. /**
  95. * @brief Returns properties that describe the render texture.
  96. */
  97. const MultiRenderTextureProperties& getProperties() const;
  98. /**
  99. * @brief Retrieves a core implementation of a render texture usable only from the
  100. * core thread.
  101. *
  102. * @note Core thread only.
  103. */
  104. SPtr<MultiRenderTextureCore> getCore() const;
  105. /**
  106. * @copydoc TextureManager::createMultiRenderTexture
  107. */
  108. static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
  109. protected:
  110. MultiRenderTexture() { }
  111. MULTI_RENDER_TEXTURE_DESC mDesc;
  112. };
  113. }