IRenderTarget.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 __I_RENDER_TARGET_H_INCLUDED__
  5. #define __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 Texture;
  36. }
  37. //! Returns a of previously set depth / depth-stencil texture.
  38. ITexture* getDepthStencil() const
  39. {
  40. return DepthStencil;
  41. }
  42. //! Set multiple textures.
  43. /** Set multiple textures for the render target.
  44. \param texture Array of texture objects. These textures are used for a color outputs.
  45. \param depthStencil Depth or packed depth-stencil texture. This texture is used as depth
  46. or depth-stencil buffer.
  47. \param cubeSurfaces When rendering to cube textures, set the surface to be used for each texture. Can be empty otherwise.
  48. */
  49. virtual void setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces = core::array<E_CUBE_SURFACE>()) = 0;
  50. //! Set one texture.
  51. void setTexture(ITexture* texture, ITexture* depthStencil)
  52. {
  53. core::array<ITexture*> textureArray(1);
  54. textureArray.push_back(texture);
  55. setTexture(textureArray, depthStencil);
  56. }
  57. //! Set one cube surface texture.
  58. void setTexture(ITexture* texture, ITexture* depthStencil, E_CUBE_SURFACE cubeSurface)
  59. {
  60. core::array<ITexture*> textureArray(1);
  61. textureArray.push_back(texture);
  62. core::array<E_CUBE_SURFACE> cubeSurfaces(1);
  63. cubeSurfaces.push_back(cubeSurface);
  64. setTexture(textureArray, depthStencil, cubeSurfaces);
  65. }
  66. //! Get driver type of render target.
  67. E_DRIVER_TYPE getDriverType() const
  68. {
  69. return DriverType;
  70. }
  71. protected:
  72. //! Textures assigned to render target.
  73. core::array<ITexture*> Texture;
  74. //! Depth or packed depth-stencil texture assigned to render target.
  75. ITexture* DepthStencil;
  76. //! Active surface of cube textures
  77. core::array<E_CUBE_SURFACE> CubeSurfaces;
  78. //! Driver type of render target.
  79. E_DRIVER_TYPE DriverType;
  80. private:
  81. // no copying (IReferenceCounted still allows that for reasons which take some time to work around)
  82. IRenderTarget(const IRenderTarget&);
  83. IRenderTarget& operator=(const IRenderTarget&);
  84. };
  85. }
  86. }
  87. #endif