Canvas.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * Copyright (c) 2006-2020 LOVE Development Team
  3. *
  4. * This software is provided 'as-is', without any express or implied
  5. * warranty. In no event will the authors be held liable for any damages
  6. * arising from the use of this software.
  7. *
  8. * Permission is granted to anyone to use this software for any purpose,
  9. * including commercial applications, and to alter it and redistribute it
  10. * freely, subject to the following restrictions:
  11. *
  12. * 1. The origin of this software must not be misrepresented; you must not
  13. * claim that you wrote the original software. If you use this software
  14. * in a product, an acknowledgment in the product documentation would be
  15. * appreciated but is not required.
  16. * 2. Altered source versions must be plainly marked as such, and must not be
  17. * misrepresented as being the original software.
  18. * 3. This notice may not be removed or altered from any source distribution.
  19. **/
  20. #ifndef LOVE_GRAPHICS_OPENGL_CANVAS_H
  21. #define LOVE_GRAPHICS_OPENGL_CANVAS_H
  22. #include "common/config.h"
  23. #include "common/Color.h"
  24. #include "common/int.h"
  25. #include "graphics/Canvas.h"
  26. #include "graphics/Volatile.h"
  27. #include "OpenGL.h"
  28. namespace love
  29. {
  30. namespace graphics
  31. {
  32. namespace opengl
  33. {
  34. class Canvas final : public love::graphics::Canvas, public Volatile
  35. {
  36. public:
  37. Canvas(const Settings &settings);
  38. virtual ~Canvas();
  39. // Implements Volatile.
  40. bool loadVolatile() override;
  41. void unloadVolatile() override;
  42. // Implements Texture.
  43. void setFilter(const Texture::Filter &f) override;
  44. bool setWrap(const Texture::Wrap &w) override;
  45. bool setMipmapSharpness(float sharpness) override;
  46. void setDepthSampleMode(Optional<CompareMode> mode) override;
  47. ptrdiff_t getHandle() const override;
  48. love::image::ImageData *newImageData(love::image::Image *module, int slice, int mipmap, const Rect &rect) override;
  49. void generateMipmaps() override;
  50. int getMSAA() const override
  51. {
  52. return actualSamples;
  53. }
  54. ptrdiff_t getRenderTargetHandle() const override
  55. {
  56. return renderbuffer != 0 ? renderbuffer : texture;
  57. }
  58. inline GLuint getFBO() const
  59. {
  60. return fbo;
  61. }
  62. static bool isMultiFormatMultiCanvasSupported();
  63. private:
  64. GLuint fbo;
  65. GLuint texture;
  66. GLuint renderbuffer;
  67. GLenum status;
  68. int actualSamples;
  69. }; // Canvas
  70. } // opengl
  71. } // graphics
  72. } // love
  73. #endif // LOVE_GRAPHICS_OPENGL_CANVAS_H