/* ============================================================================== This file is part of the JUCE library - "Jules' Utility Class Extensions" Copyright 2004-11 by Raw Material Software Ltd. ------------------------------------------------------------------------------ JUCE can be redistributed and/or modified under the terms of the GNU General Public License (Version 2), as published by the Free Software Foundation. A copy of the license is included in the JUCE distribution, or can be found online at www.gnu.org/licenses. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ------------------------------------------------------------------------------ To release a closed-source product which uses JUCE, commercial licenses are available: visit www.rawmaterialsoftware.com/juce for more information. ============================================================================== */ #ifndef __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__ #define __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__ //============================================================================== /** Creates an openGL frame buffer. */ class JUCE_API OpenGLFrameBuffer { public: /** Creates an uninitialised buffer. To actually allocate the buffer, use initialise(). */ OpenGLFrameBuffer(); /** Destructor. */ ~OpenGLFrameBuffer(); //============================================================================== /** Tries to allocates a buffer of the given size. Note that a valid openGL context must be selected when you call this method, or it will fail. */ bool initialise (int width, int height); /** Releases the buffer, if one has been allocated. */ void release(); /** Returns true if a valid buffer has been allocated. */ bool isValid() const noexcept { return pimpl != nullptr; } /** Returns the width of the buffer. */ int getWidth() const noexcept; /** Returns the height of the buffer. */ int getHeight() const noexcept; /** Returns the texture ID number for using this buffer as a texture. */ unsigned int getTextureID() const noexcept; //============================================================================== /** Selects this buffer as the current OpenGL rendering target. */ bool makeCurrentTarget(); /** Deselects this buffer as the current OpenGL rendering target. */ void releaseCurrentTarget(); /** Clears the framebuffer with the specified colour. */ void clear (const Colour& colour); /** Draws this framebuffer onto the current context, with the specified corner positions. */ void draw2D (float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, const Colour& colour) const; /** Draws this framebuffer onto the current context, with the specified corner positions. */ void draw3D (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, const Colour& colour) const; private: class Pimpl; friend class ScopedPointer; ScopedPointer pimpl; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OpenGLFrameBuffer); }; #endif // __JUCE_OPENGLFRAMEBUFFER_JUCEHEADER__