IRenderTarget.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Copyright (C) 2015 Patryk Nadrowski
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_RENDER_TARGET_H_INCLUDED
  5. #define IRR_I_RENDER_TARGET_H_INCLUDED
  6. #include "IReferenceCounted.h"
  7. #include "EDriverTypes.h"
  8. #include "irrArray.h"
  9. namespace irr
  10. {
  11. namespace video
  12. {
  13. class ITexture;
  14. //! Enumeration of cube texture surfaces
  15. enum E_CUBE_SURFACE
  16. {
  17. ECS_POSX = 0,
  18. ECS_NEGX,
  19. ECS_POSY,
  20. ECS_NEGY,
  21. ECS_POSZ,
  22. ECS_NEGZ
  23. };
  24. //! Interface of a Render Target.
  25. class IRenderTarget : public virtual IReferenceCounted
  26. {
  27. public:
  28. //! constructor
  29. IRenderTarget() : DepthStencil(0), DriverType(EDT_NULL)
  30. {
  31. }
  32. //! Returns an array of previously set textures.
  33. const core::array<ITexture*>& getTexture() const
  34. {
  35. return Textures;
  36. }
  37. //! Returns a of previously set depth / depth-stencil texture.
  38. ITexture* getDepthStencil() const
  39. {
  40. return DepthStencil;
  41. }
  42. //! Returns an array of active surface for cube textures
  43. const core::array<E_CUBE_SURFACE>& getCubeSurfaces() const
  44. {
  45. return CubeSurfaces;
  46. }
  47. //! Set multiple textures.
  48. /** Set multiple textures for the render target.
  49. \param texture Array of texture objects. These textures are used for a color outputs.
  50. \param depthStencil Depth or packed depth-stencil texture. This texture is used as depth
  51. or depth-stencil buffer. You can pass getDepthStencil() if you don't want to change it.
  52. \param cubeSurfaces When rendering to cube textures, set the surface to be used for each texture. Can be empty otherwise.
  53. */
  54. void setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces = core::array<E_CUBE_SURFACE>())
  55. {
  56. setTextures(texture.const_pointer(), texture.size(), depthStencil, cubeSurfaces.const_pointer(), cubeSurfaces.size());
  57. }
  58. //! Sets one texture + depthStencil
  59. //! You can pass getDepthStencil() for depthStencil if you don't want to change that one
  60. void setTexture(ITexture* texture, ITexture* depthStencil)
  61. {
  62. if ( texture )
  63. {
  64. setTextures(&texture, 1, depthStencil);
  65. }
  66. else
  67. {
  68. setTextures(0, 0, depthStencil);
  69. }
  70. }
  71. //! Set one cube surface texture.
  72. void setTexture(ITexture* texture, ITexture* depthStencil, E_CUBE_SURFACE cubeSurface)
  73. {
  74. if ( texture )
  75. {
  76. setTextures(&texture, 1, depthStencil, &cubeSurface, 1);
  77. }
  78. else
  79. {
  80. setTextures(0, 0, depthStencil, &cubeSurface, 1);
  81. }
  82. }
  83. //! Get driver type of render target.
  84. E_DRIVER_TYPE getDriverType() const
  85. {
  86. return DriverType;
  87. }
  88. protected:
  89. //! Set multiple textures.
  90. // NOTE: working with pointers instead of arrays to avoid unnecessary memory allocations for the single textures case
  91. virtual void setTextures(ITexture* const * textures, u32 numTextures, ITexture* depthStencil, const E_CUBE_SURFACE* cubeSurfaces=0, u32 numCubeSurfaces=0) = 0;
  92. //! Textures assigned to render target.
  93. core::array<ITexture*> Textures;
  94. //! Depth or packed depth-stencil texture assigned to render target.
  95. ITexture* DepthStencil;
  96. //! Active surface of cube textures
  97. core::array<E_CUBE_SURFACE> CubeSurfaces;
  98. //! Driver type of render target.
  99. E_DRIVER_TYPE DriverType;
  100. private:
  101. // no copying (IReferenceCounted still allows that for reasons which take some time to work around)
  102. IRenderTarget(const IRenderTarget&);
  103. IRenderTarget& operator=(const IRenderTarget&);
  104. };
  105. }
  106. }
  107. #endif