Creates an openGL frame buffer.
Public Types | |
| enum class | RowOrder { fromBottomUp , fromTopDown } |
Public Member Functions | |
| OpenGLFrameBuffer () | |
| Creates an uninitialised buffer. | |
| ~OpenGLFrameBuffer () | |
| Destructor. | |
| bool | initialise (OpenGLContext &context, int width, int height) |
| Tries to allocates a buffer of the given size. | |
| bool | initialise (OpenGLContext &context, const Image &content) |
| Tries to allocates a buffer containing a copy of a given image. | |
| bool | initialise (OpenGLFrameBuffer &other) |
| Tries to allocate a copy of another framebuffer. | |
| void | release () |
| Releases the buffer, if one has been allocated. | |
| void | saveAndRelease () |
| If the framebuffer is active, this will save a stashed copy of its contents in main memory, and will release the GL buffer. | |
| bool | reloadSavedCopy (OpenGLContext &context) |
| Restores the framebuffer content that was previously saved using saveAndRelease(). | |
| bool | isValid () const noexcept |
| Returns true if a valid buffer has been allocated. | |
| int | getWidth () const noexcept |
| Returns the width of the buffer. | |
| int | getHeight () const noexcept |
| Returns the height of the buffer. | |
| GLuint | getTextureID () const noexcept |
| Returns the texture ID number for using this buffer as a texture. | |
| int | getTextureWidth () const noexcept |
| Returns the width of the texture that backs this buffer. | |
| int | getTextureHeight () const noexcept |
| Returns the height of the texture that backs this buffer. | |
| bool | makeCurrentRenderingTarget () |
| Selects this buffer as the current OpenGL rendering target. | |
| void | releaseAsRenderingTarget () |
| Deselects this buffer as the current OpenGL rendering target. | |
| GLuint | getFrameBufferID () const noexcept |
| Returns the ID of this framebuffer, or 0 if it isn't initialised. | |
| void | clear (Colour colour) |
| Clears the framebuffer with the specified colour. | |
| void | makeCurrentAndClear () |
| Selects the framebuffer as the current target, and clears it to transparent. | |
| bool | readPixels (PixelARGB *targetData, const Rectangle< int > &sourceArea, RowOrder order) |
| Reads an area of pixels from the framebuffer into a 32-bit ARGB pixel array. | |
| bool | writePixels (const PixelARGB *srcData, const Rectangle< int > &targetArea, RowOrder order) |
| Writes an area of pixels into the framebuffer from a specified pixel array. | |
Static Public Member Functions | |
| static GLuint | getCurrentFrameBufferTarget () noexcept |
| Returns the current frame buffer ID for the current context. | |
|
strong |
| juce::OpenGLFrameBuffer::OpenGLFrameBuffer | ( | ) |
Creates an uninitialised buffer.
To actually allocate the buffer, use initialise().
Referenced by initialise(), and writePixels().
| juce::OpenGLFrameBuffer::~OpenGLFrameBuffer | ( | ) |
Destructor.
| bool juce::OpenGLFrameBuffer::initialise | ( | OpenGLContext & | context, |
| int | width, | ||
| int | height ) |
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 juce::OpenGLFrameBuffer::initialise | ( | OpenGLContext & | context, |
| const Image & | content ) |
Tries to allocates a buffer containing a copy of a given image.
Note that a valid openGL context must be selected when you call this method, or it will fail.
| bool juce::OpenGLFrameBuffer::initialise | ( | OpenGLFrameBuffer & | other | ) |
Tries to allocate a copy of another framebuffer.
References OpenGLFrameBuffer().
| void juce::OpenGLFrameBuffer::release | ( | ) |
Releases the buffer, if one has been allocated.
Any saved state that was created with saveAndRelease() will also be freed by this call.
| void juce::OpenGLFrameBuffer::saveAndRelease | ( | ) |
If the framebuffer is active, this will save a stashed copy of its contents in main memory, and will release the GL buffer.
After saving, the original state can be restored again by calling reloadSavedCopy().
| bool juce::OpenGLFrameBuffer::reloadSavedCopy | ( | OpenGLContext & | context | ) |
Restores the framebuffer content that was previously saved using saveAndRelease().
|
noexcept |
Returns true if a valid buffer has been allocated.
|
noexcept |
|
noexcept |
|
noexcept |
Returns the texture ID number for using this buffer as a texture.
The texture may be larger than the buffer itself, see getTextureWidth() and getTextureHeight(). The buffer's content occupies the top-left corner of the texture, so the top-left pixel of the buffer is at texture coordinate (0, 1).
References getTextureID().
Referenced by getTextureID().
|
noexcept |
Returns the width of the texture that backs this buffer.
This is normally the same as getWidth(), but if the GL implementation is unable to create a texture with the exact size that was requested, a larger texture will be used instead, and this will return the actual width of that texture.
References getTextureWidth().
Referenced by getTextureWidth().
|
noexcept |
Returns the height of the texture that backs this buffer.
References getTextureHeight().
Referenced by getTextureHeight().
| bool juce::OpenGLFrameBuffer::makeCurrentRenderingTarget | ( | ) |
Selects this buffer as the current OpenGL rendering target.
References makeCurrentRenderingTarget().
Referenced by makeCurrentRenderingTarget().
| void juce::OpenGLFrameBuffer::releaseAsRenderingTarget | ( | ) |
Deselects this buffer as the current OpenGL rendering target.
References releaseAsRenderingTarget().
Referenced by releaseAsRenderingTarget().
|
noexcept |
Returns the ID of this framebuffer, or 0 if it isn't initialised.
References getFrameBufferID().
Referenced by getFrameBufferID().
|
staticnoexcept |
Returns the current frame buffer ID for the current context.
References getCurrentFrameBufferTarget().
Referenced by getCurrentFrameBufferTarget().
| void juce::OpenGLFrameBuffer::clear | ( | Colour | colour | ) |
| void juce::OpenGLFrameBuffer::makeCurrentAndClear | ( | ) |
Selects the framebuffer as the current target, and clears it to transparent.
References makeCurrentAndClear().
Referenced by makeCurrentAndClear().
| bool juce::OpenGLFrameBuffer::readPixels | ( | PixelARGB * | targetData, |
| const Rectangle< int > & | sourceArea, | ||
| RowOrder | order ) |
Reads an area of pixels from the framebuffer into a 32-bit ARGB pixel array.
| targetData | the array to fill. It must have room for at least sourceArea.getWidth() * sourceArea.getHeight() pixels, which are written contiguously with no padding between rows. |
| sourceArea | the area to read, in OpenGL coordinates, with its origin at the bottom-left corner of the framebuffer. |
| order | the order in which the rows of the area are written to targetData. |
| bool juce::OpenGLFrameBuffer::writePixels | ( | const PixelARGB * | srcData, |
| const Rectangle< int > & | targetArea, | ||
| RowOrder | order ) |
Writes an area of pixels into the framebuffer from a specified pixel array.
| srcData | the pixels to write. It must contain at least targetArea.getWidth() * targetArea.getHeight() pixels, stored contiguously with no padding between rows. |
| targetArea | the area to write, in OpenGL coordinates, with its origin at the bottom-left corner of the framebuffer. |
| order | the order of the rows in srcData. |
References OpenGLFrameBuffer().