Louvre  v1.2.1-2
C++ library for Wayland compositors
List of all members | Public Member Functions
LRenderBuffer Class Reference

#include <LRenderBuffer.h>

Custom render destination framebuffer. More...

Detailed Description

Custom render destination framebuffer.

The LRenderBuffer can be utilized to render to a framebuffer instead of an LOutput and then use that rendered content as a texture.
Essentially, it acts as a wrapper for an OpenGL framebuffer with additional functionality. You can obtain the OpenGL framebuffer ID using the id() method. It can also be utilized with an LPainter by using LPainter::bindFramebuffer().

Note
A framebuffer possess properties such as position, size, and buffer scale. LPainter uses these properties to properly position and scale the rendered content.

Public Member Functions

 LRenderBuffer (const LSize &sizeB, bool alpha=true)
 Constructor for LRenderBuffer with specified size. More...
 
 ~LRenderBuffer ()
 Destructor for LRenderBuffer. More...
 
GLuint id () const override
 Retrieve the OpenGL ID of the framebuffer. More...
 
const LTexturetexture (Int32 index=0) const override
 Retrieve the texture associated with the framebuffer. More...
 
void setSizeB (const LSize &sizeB)
 Set the size of the framebuffer in buffer coordinates. More...
 
const LSizesizeB () const override
 Retrieve the size of the framebuffer in buffer coordinates. More...
 
const LSizesize () const
 Retrieve the size of the framebuffer. More...
 
void setPos (const LPoint &pos)
 Set the position of the framebuffer. More...
 
const LPointpos () const
 Retrieve the position of the framebuffer. More...
 
const LRectrect () const override
 Retrieve the position and size of the framebuffer in surface coordinates. More...
 
void setScale (Float32 scale) const
 Set the buffer scale to properly scale the rendered content. More...
 
Float32 scale () const override
 Retrieve the buffer scale of the framebuffer. More...
 
Int32 buffersCount () const override
 Get the number of framebuffers represented by this instance. More...
 
Int32 currentBufferIndex () const override
 Get the index of the framebuffer where the rendering is stored. More...
 
void setFramebufferDamage (const LRegion *damage) override
 Set the damaged region. More...
 
Transform transform () const override
 Get the framebuffer transformation. More...
 
- Public Member Functions inherited from LFramebuffer
Type type () const
 
virtual ~LFramebuffer ()
 Destructor for the LFramebuffer class. More...
 
- Public Member Functions inherited from LObject
 LObject ()=default
 Constructor of the LObject class. More...
 
 ~LObject ()
 Destructor of the LObject class. More...
 
std::shared_ptr< const bool > isAlive () const
 Object's liveness status. More...
 

Additional Inherited Members

- Public Types inherited from LFramebuffer
enum  Type
 
enum  Transform : Int32
 Enumeration for Framebuffer Transformations. More...
 
- Static Public Member Functions inherited from LFramebuffer
static bool is90Transform (Transform transform)
 
static Transform requiredTransform (Transform from, Transform to)
 
- Static Public Member Functions inherited from LObject
static LCompositorcompositor ()
 Quick access to the global compositor instance. More...
 
static LSeatseat ()
 Quick access to the global seat instance. More...
 
static LCursorcursor ()
 Quick access to the global cursor instance. More...
 
- Protected Attributes inherited from LFramebuffer
Type m_type
 

Constructor & Destructor Documentation

◆ LRenderBuffer()

LRenderBuffer ( const LSize sizeB,
bool  alpha = true 
)

Constructor for LRenderBuffer with specified size.

This constructor creates an LRenderBuffer with the specified size in buffer coordinates.

Parameters
sizeBThe size of the framebuffer in buffer coordinates.
alphaEmploy a format with an alpha component.

◆ ~LRenderBuffer()

Destructor for LRenderBuffer.

Member Function Documentation

◆ id()

GLuint id ( ) const
overridevirtual

Retrieve the OpenGL ID of the framebuffer.

This method returns the OpenGL ID of the framebuffer associated with the LRenderBuffer.

Returns
The OpenGL ID of the framebuffer.

Implements LFramebuffer.

◆ texture()

const LTexture * texture ( Int32  index = 0) const
overridevirtual

Retrieve the texture associated with the framebuffer.

LRenderBuffers always have a single framebuffer, so 0 must always be passed as an argument. The index is part of the LFramebuffer parent class, which may be used by special framebuffers like those of LOutput.

Parameters
indexThe index of the texture (default is 0).
Returns
A pointer to the texture associated with the framebuffer.

Implements LFramebuffer.

◆ setSizeB()

void setSizeB ( const LSize sizeB)

Set the size of the framebuffer in buffer coordinates.

Warning
The existing framebuffer is destroyed and replaced by a new one each time this method is called, so it should be used with moderation.
Parameters
sizeBThe new size of the framebuffer in buffer coordinates.

◆ sizeB()

const LSize & sizeB ( ) const
overridevirtual

Retrieve the size of the framebuffer in buffer coordinates.

This method returns the size of the framebuffer in buffer coordinates.

Returns
The size of the framebuffer.

Implements LFramebuffer.

◆ size()

const LSize & size ( ) const

Retrieve the size of the framebuffer.

This method returns the size of the framebuffer in surface coordinates. This is sizeB() / scale().

Returns
The size of the framebuffer.

◆ setPos()

void setPos ( const LPoint pos)

Set the position of the framebuffer.

This method sets the position of the framebuffer in surface coordinates.

Parameters
posThe new position of the framebuffer.

◆ pos()

const LPoint & pos ( ) const

Retrieve the position of the framebuffer.

This method returns the position of the framebuffer in surface coordinates.

Returns
The position of the framebuffer.

◆ rect()

const LRect & rect ( ) const
overridevirtual

Retrieve the position and size of the framebuffer in surface coordinates.

The size provided by this rect is equal to size().

Returns
The position and size of the framebuffer in surface coordinates.

Implements LFramebuffer.

◆ setScale()

void setScale ( Float32  scale) const

Set the buffer scale to properly scale the rendered content.

For example, framebuffers used in HiDPI displays should have a scale of 2 or greater.

Parameters
scaleThe buffer scale factor.

◆ scale()

Float32 scale ( ) const
overridevirtual

Retrieve the buffer scale of the framebuffer.

This method returns the buffer scale factor of the framebuffer.

Returns
The buffer scale factor.

Implements LFramebuffer.

◆ buffersCount()

Int32 buffersCount ( ) const
overridevirtual

Get the number of framebuffers represented by this instance.

This method must return the number of framebuffers represented by this instance.

Returns
The number of framebuffers.

Implements LFramebuffer.

◆ currentBufferIndex()

Int32 currentBufferIndex ( ) const
overridevirtual

Get the index of the framebuffer where the rendering is stored.

This method must return the index of the framebuffer where rendering must be performed/stored.

Returns
The index of the framebuffer used for rendering.

Implements LFramebuffer.

◆ setFramebufferDamage()

void setFramebufferDamage ( const LRegion damage)
overridevirtual

Set the damaged region.

This method sets the region in surface coordinates that indicates the parts of the framebuffer that have changed since the last painting was performed.

Parameters
damageA pointer to the LRegion object representing the changed region.

Implements LFramebuffer.

◆ transform()

LFramebuffer::Transform transform ( ) const
overridevirtual

Get the framebuffer transformation.

This method must return the current framebuffer transformation applied.

Returns
The framebuffer transformation.

Implements LFramebuffer.