JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::OpenGLFrameBuffer Class Reference

Creates an openGL frame buffer. More...

#include <juce_OpenGLFrameBuffer.h>

Collaboration diagram for juce::OpenGLFrameBuffer:

Public Member Functions

 OpenGLFrameBuffer ()
 Creates an uninitialised buffer. More...
 
 ~OpenGLFrameBuffer ()
 Destructor. More...
 
void clear (Colour colour)
 Clears the framebuffer with the specified colour. More...
 
GLuint getFrameBufferID () const noexcept
 Returns the ID of this framebuffer, or 0 if it isn't initialised. More...
 
int getHeight () const noexcept
 Returns the height of the buffer. More...
 
GLuint getTextureID () const noexcept
 Returns the texture ID number for using this buffer as a texture. More...
 
int getWidth () const noexcept
 Returns the width of the buffer. More...
 
bool initialise (OpenGLContext &context, int width, int height)
 Tries to allocates a buffer of the given size. More...
 
bool initialise (OpenGLContext &context, const Image &content)
 Tries to allocates a buffer containing a copy of a given image. More...
 
bool initialise (OpenGLFrameBuffer &other)
 Tries to allocate a copy of another framebuffer. More...
 
bool isValid () const noexcept
 Returns true if a valid buffer has been allocated. More...
 
void makeCurrentAndClear ()
 Selects the framebuffer as the current target, and clears it to transparent. More...
 
bool makeCurrentRenderingTarget ()
 Selects this buffer as the current OpenGL rendering target. More...
 
bool readPixels (PixelARGB *targetData, const Rectangle< int > &sourceArea)
 Reads an area of pixels from the framebuffer into a 32-bit ARGB pixel array. More...
 
void release ()
 Releases the buffer, if one has been allocated. More...
 
void releaseAsRenderingTarget ()
 Deselects this buffer as the current OpenGL rendering target. More...
 
bool reloadSavedCopy (OpenGLContext &context)
 Restores the framebuffer content that was previously saved using saveAndRelease(). More...
 
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. More...
 
bool writePixels (const PixelARGB *srcData, const Rectangle< int > &targetArea)
 Writes an area of pixels into the framebuffer from a specified pixel array. More...
 

Static Public Member Functions

static GLuint getCurrentFrameBufferTarget () noexcept
 Returns the current frame buffer ID for the current context. More...
 

Private Attributes

std::unique_ptr< Pimpl > pimpl
 
std::unique_ptr< SavedState > savedState
 

Detailed Description

Creates an openGL frame buffer.

{OpenGL}

Constructor & Destructor Documentation

◆ OpenGLFrameBuffer()

juce::OpenGLFrameBuffer::OpenGLFrameBuffer ( )

Creates an uninitialised buffer.

To actually allocate the buffer, use initialise().

◆ ~OpenGLFrameBuffer()

juce::OpenGLFrameBuffer::~OpenGLFrameBuffer ( )

Destructor.

Member Function Documentation

◆ clear()

void juce::OpenGLFrameBuffer::clear ( Colour  colour)

Clears the framebuffer with the specified colour.

◆ getCurrentFrameBufferTarget()

static GLuint juce::OpenGLFrameBuffer::getCurrentFrameBufferTarget ( )
staticnoexcept

Returns the current frame buffer ID for the current context.

◆ getFrameBufferID()

GLuint juce::OpenGLFrameBuffer::getFrameBufferID ( ) const
noexcept

Returns the ID of this framebuffer, or 0 if it isn't initialised.

◆ getHeight()

int juce::OpenGLFrameBuffer::getHeight ( ) const
noexcept

Returns the height of the buffer.

◆ getTextureID()

GLuint juce::OpenGLFrameBuffer::getTextureID ( ) const
noexcept

Returns the texture ID number for using this buffer as a texture.

◆ getWidth()

int juce::OpenGLFrameBuffer::getWidth ( ) const
noexcept

Returns the width of the buffer.

◆ initialise() [1/3]

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.

◆ initialise() [2/3]

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.

◆ initialise() [3/3]

bool juce::OpenGLFrameBuffer::initialise ( OpenGLFrameBuffer other)

Tries to allocate a copy of another framebuffer.

◆ isValid()

bool juce::OpenGLFrameBuffer::isValid ( ) const
inlinenoexcept

Returns true if a valid buffer has been allocated.

◆ makeCurrentAndClear()

void juce::OpenGLFrameBuffer::makeCurrentAndClear ( )

Selects the framebuffer as the current target, and clears it to transparent.

◆ makeCurrentRenderingTarget()

bool juce::OpenGLFrameBuffer::makeCurrentRenderingTarget ( )

Selects this buffer as the current OpenGL rendering target.

◆ readPixels()

bool juce::OpenGLFrameBuffer::readPixels ( PixelARGB targetData,
const Rectangle< int > &  sourceArea 
)

Reads an area of pixels from the framebuffer into a 32-bit ARGB pixel array.

The lineStride is measured as a number of pixels, not bytes - pass a stride of 0 to indicate a packed array.

◆ release()

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.

◆ releaseAsRenderingTarget()

void juce::OpenGLFrameBuffer::releaseAsRenderingTarget ( )

Deselects this buffer as the current OpenGL rendering target.

◆ reloadSavedCopy()

bool juce::OpenGLFrameBuffer::reloadSavedCopy ( OpenGLContext context)

Restores the framebuffer content that was previously saved using saveAndRelease().

After saving to main memory, the original state can be restored by calling restoreToGPUMemory().

◆ saveAndRelease()

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().

◆ writePixels()

bool juce::OpenGLFrameBuffer::writePixels ( const PixelARGB srcData,
const Rectangle< int > &  targetArea 
)

Writes an area of pixels into the framebuffer from a specified pixel array.

The lineStride is measured as a number of pixels, not bytes - pass a stride of 0 to indicate a packed array.

Member Data Documentation

◆ pimpl

std::unique_ptr<Pimpl> juce::OpenGLFrameBuffer::pimpl
private

◆ savedState

std::unique_ptr<SavedState> juce::OpenGLFrameBuffer::savedState
private

The documentation for this class was generated from the following file: