RenderBuffer.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /****************************************************************************
  2. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #pragma once
  21. #include "../Macro.h"
  22. #include "renderer/Types.h"
  23. #include "RenderTarget.h"
  24. RENDERER_BEGIN
  25. /**
  26. * @addtogroup gfx
  27. * @{
  28. */
  29. class DeviceGraphics;
  30. /**
  31. * RenderBuffer manages the GL render buffer.
  32. * A render buffer stores data such as an image, or can be source or target of a rendering operation.
  33. */
  34. class RenderBuffer final : public RenderTarget
  35. {
  36. public:
  37. /**
  38. * RenderBuffer's pixel format
  39. */
  40. enum class Format : uint32_t
  41. {
  42. RGBA4 = GL_RGBA4,
  43. RGB5_A1 = GL_RGB5_A1,
  44. D16 = GL_DEPTH_COMPONENT16,
  45. S8 = GL_STENCIL_INDEX8,
  46. // D24S8 = GL_DEPTH_STENCIL
  47. };
  48. /**
  49. * Creates a RenderBuffer with device, pixel format and size
  50. */
  51. RENDERER_DEFINE_CREATE_METHOD_4(RenderBuffer, init, DeviceGraphics*, Format, uint16_t, uint16_t)
  52. RenderBuffer();
  53. virtual ~RenderBuffer();
  54. /**
  55. * Initializes a RenderBuffer with device, pixel format and size
  56. */
  57. bool init(DeviceGraphics* device, Format format, uint16_t width, uint16_t height);
  58. private:
  59. DeviceGraphics* _device;
  60. Format _format;
  61. uint16_t _width;
  62. uint16_t _height;
  63. };
  64. // end of gfx group
  65. /// @}
  66. RENDERER_END