RenderTarget.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef RENDERTARGET_H_
  2. #define RENDERTARGET_H_
  3. #include "Base.h"
  4. #include "Texture.h"
  5. namespace gameplay
  6. {
  7. /**
  8. * Represents a linear area of display memory and usually reside
  9. * in the display memory of the display card.
  10. */
  11. class RenderTarget : public Ref
  12. {
  13. friend class FrameBuffer;
  14. public:
  15. /**
  16. * Create a RenderTarget and add it to the list of available RenderTargets.
  17. *
  18. * The created RenderTarget contains a 32-bit texture with a single/base mipmap level only.
  19. *
  20. * @param id The ID of the new RenderTarget.
  21. * @param width The width of the new RenderTarget.
  22. * @param height The height of the new RenderTarget.
  23. *
  24. * @return A newly created RenderTarget.
  25. * @script{create}
  26. */
  27. static RenderTarget* create(const char* id, unsigned int width, unsigned int height);
  28. /**
  29. * Create a RenderTarget from the given Texture and add it to the list of
  30. * available RenderTargets.
  31. *
  32. * Note that different hardware and OpenGL versions have different capabilities
  33. * and restrictions on what texture formats are supported as render targets.
  34. *
  35. * @param id The ID of the new RenderTarget.
  36. * @param texture The texture for the new RenderTarget.
  37. *
  38. * @return A newly created RenderTarget.
  39. * @script{create}
  40. */
  41. static RenderTarget* create(const char* id, Texture* texture);
  42. /**
  43. * Get a named RenderTarget from its ID.
  44. *
  45. * @param id The ID of the RenderTarget to search for.
  46. *
  47. * @return The RenderTarget with the specified ID, or NULL if one was not found.
  48. */
  49. static RenderTarget* getRenderTarget(const char* id);
  50. /**
  51. * Get the ID of this RenderTarget.
  52. *
  53. * @return The ID of this RenderTarget.
  54. */
  55. const char* getId() const;
  56. /**
  57. * Get the backing texture of this RenderTarget.
  58. *
  59. * @return The backing texture of this RenderTarget.
  60. */
  61. Texture* getTexture() const;
  62. /**
  63. * Returns the width of the RenderTarget.
  64. *
  65. * @return The width.
  66. */
  67. unsigned int getWidth() const;
  68. /**
  69. * Returns the height of the RenderTarget.
  70. *
  71. * @return The height.
  72. */
  73. unsigned int getHeight() const;
  74. private:
  75. /**
  76. * Constructor.
  77. */
  78. RenderTarget(const char* id);
  79. /**
  80. * Destructor.
  81. */
  82. ~RenderTarget();
  83. /**
  84. * Hidden copy assignment operator.
  85. */
  86. RenderTarget& operator=(const RenderTarget&);
  87. std::string _id;
  88. Texture* _texture;
  89. };
  90. }
  91. #endif