The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__
  19. #define __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__
  20. //==============================================================================
  21. /**
  22. Creates an openGL frame buffer.
  23. */
  24. class JUCE_API OpenGLFrameBuffer
  25. {
  26. public:
  27. /** Creates an uninitialised buffer.
  28. To actually allocate the buffer, use initialise().
  29. */
  30. OpenGLFrameBuffer();
  31. /** Destructor. */
  32. ~OpenGLFrameBuffer();
  33. //==============================================================================
  34. /** Tries to allocates a buffer of the given size.
  35. Note that a valid openGL context must be selected when you call this method,
  36. or it will fail.
  37. */
  38. bool initialise (int width, int height);
  39. /** Releases the buffer, if one has been allocated. */
  40. void release();
  41. /** Returns true if a valid buffer has been allocated. */
  42. bool isValid() const noexcept { return pimpl != nullptr; }
  43. /** Returns the width of the buffer. */
  44. int getWidth() const noexcept;
  45. /** Returns the height of the buffer. */
  46. int getHeight() const noexcept;
  47. /** Returns the texture ID number for using this buffer as a texture. */
  48. unsigned int getTextureID() const noexcept;
  49. //==============================================================================
  50. /** Selects this buffer as the current OpenGL rendering target. */
  51. bool makeCurrentTarget();
  52. /** Deselects this buffer as the current OpenGL rendering target. */
  53. void releaseCurrentTarget();
  54. /** Clears the framebuffer with the specified colour. */
  55. void clear (const Colour& colour);
  56. /** Draws this framebuffer onto the current context, with the specified corner positions. */
  57. void draw2D (float x1, float y1,
  58. float x2, float y2,
  59. float x3, float y3,
  60. float x4, float y4,
  61. const Colour& colour) const;
  62. /** Draws this framebuffer onto the current context, with the specified corner positions. */
  63. void draw3D (float x1, float y1, float z1,
  64. float x2, float y2, float z2,
  65. float x3, float y3, float z3,
  66. float x4, float y4, float z4,
  67. const Colour& colour) const;
  68. private:
  69. class Pimpl;
  70. friend class ScopedPointer<Pimpl>;
  71. ScopedPointer<Pimpl> pimpl;
  72. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLFrameBuffer);
  73. };
  74. #endif // __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__