IRenderTarget.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #pragma once
  5. #include "IReferenceCounted.h"
  6. #include "EDriverTypes.h"
  7. #include "irrArray.h"
  8. namespace irr
  9. {
  10. namespace video
  11. {
  12. class ITexture;
  13. //! Enumeration of cube texture surfaces
  14. enum E_CUBE_SURFACE
  15. {
  16. ECS_POSX = 0,
  17. ECS_NEGX,
  18. ECS_POSY,
  19. ECS_NEGY,
  20. ECS_POSZ,
  21. ECS_NEGZ
  22. };
  23. //! Interface of a Render Target.
  24. class IRenderTarget : public virtual IReferenceCounted
  25. {
  26. public:
  27. //! constructor
  28. IRenderTarget() :
  29. 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. setTextures(&texture, 1, depthStencil);
  64. } else {
  65. setTextures(0, 0, depthStencil);
  66. }
  67. }
  68. //! Set one cube surface texture.
  69. void setTexture(ITexture *texture, ITexture *depthStencil, E_CUBE_SURFACE cubeSurface)
  70. {
  71. if (texture) {
  72. setTextures(&texture, 1, depthStencil, &cubeSurface, 1);
  73. } else {
  74. setTextures(0, 0, depthStencil, &cubeSurface, 1);
  75. }
  76. }
  77. //! Get driver type of render target.
  78. E_DRIVER_TYPE getDriverType() const
  79. {
  80. return DriverType;
  81. }
  82. protected:
  83. //! Set multiple textures.
  84. // NOTE: working with pointers instead of arrays to avoid unnecessary memory allocations for the single textures case
  85. virtual void setTextures(ITexture *const *textures, u32 numTextures, ITexture *depthStencil, const E_CUBE_SURFACE *cubeSurfaces = 0, u32 numCubeSurfaces = 0) = 0;
  86. //! Textures assigned to render target.
  87. core::array<ITexture *> Textures;
  88. //! Depth or packed depth-stencil texture assigned to render target.
  89. ITexture *DepthStencil;
  90. //! Active surface of cube textures
  91. core::array<E_CUBE_SURFACE> CubeSurfaces;
  92. //! Driver type of render target.
  93. E_DRIVER_TYPE DriverType;
  94. private:
  95. // no copying (IReferenceCounted still allows that for reasons which take some time to work around)
  96. IRenderTarget(const IRenderTarget &);
  97. IRenderTarget &operator=(const IRenderTarget &);
  98. };
  99. }
  100. }