Louvre
v2.13.0-1
C++ library for Wayland compositors
|
Basic 2D rendering utility. More...
Classes | |
struct | TextureParams |
Parameters required for bindTextureMode(). More... | |
Public Member Functions | |
void | bindTextureMode (const TextureParams ¶ms) noexcept |
Switches to texture mode. More... | |
void | bindColorMode () noexcept |
Switches to color mode. More... | |
void | drawBox (const LBox &box) noexcept |
Draws a texture or color box on the screen based on the current rendering mode. More... | |
void | drawRect (const LRect &rect) noexcept |
Draws a texture or color rect on the screen based on the current rendering mode. More... | |
void | drawRegion (const LRegion ®ion) noexcept |
Draws a texture or color region on the screen based on the current rendering mode. More... | |
void | enableCustomTextureColor (bool enabled) noexcept |
Enables or disables a custom texture color. More... | |
bool | customTextureColorEnabled () const noexcept |
Checks if custom texture color is enabled. More... | |
bool | autoBlendFuncEnabled () const noexcept |
Checks if automatic blending function selection is enabled. More... | |
void | enableAutoBlendFunc (bool enabled) const noexcept |
Toggles automatic blending function selection. More... | |
void | setBlendFunc (const LBlendFunc &blendFunc) const noexcept |
Sets a custom blend function. More... | |
void | setAlpha (Float32 alpha) noexcept |
Sets the alpha value. More... | |
void | setColor (const LRGBF &color) noexcept |
Sets the color. More... | |
void | setColorFactor (Float32 r, Float32 g, Float32 b, Float32 a) noexcept |
Sets the color factor. More... | |
void | setColorFactor (const LRGBAF &factor) noexcept |
Sets the color factor. More... | |
void | setClearColor (Float32 r, Float32 g, Float32 b, Float32 a) noexcept |
Sets the clear color. More... | |
void | setClearColor (const LRGBAF &color) noexcept |
Set the clear color. More... | |
void | clearScreen () noexcept |
Clear the framebuffer. More... | |
void | setViewport (const LRect &rect) noexcept |
Sets the viewport. More... | |
void | setViewport (Int32 x, Int32 y, Int32 w, Int32 h) noexcept |
Sets the viewport. More... | |
void | bindFramebuffer (LFramebuffer *framebuffer) noexcept |
Binds the specified framebuffer for rendering. More... | |
LFramebuffer * | boundFramebuffer () const noexcept |
Retrieves the currently bound framebuffer. More... | |
void | bindProgram () noexcept |
Bind the internal LPainter program. More... | |
Basic 2D rendering utility.
The LPainter class offers essential methods for 2D rendering without the need to use OpenGL functions directly.
It can draw solid colors and textures with custom clipping, scaling, blending effects, and transforms.
Each LOutput has its own LPainter, accessible via LOutput::painter().
When specifying the destination rectangle for your painting operations, use compositor-global coordinates, which operate with surface units.
LPainter automatically scales and transforms the content for you, considering the scale factor/transform of the texture you are drawing and the scale factor/transform of the destination framebuffer.
The coordinate space in which the content is rendered aligns with that used to arrange outputs.
For example, to paint something in the upper-left corner of an LOutput, consider the LOutput::pos().
struct Louvre::LPainter::TextureParams |
Parameters required for bindTextureMode().
This struct provides all the necessary parameters to map a texture into the current destination framebuffer.
Class Members | ||
---|---|---|
LTexture * | texture | Texture to be drawn. |
LPoint | pos | Position of the texture (destination rect) in compositor-global coordinates. |
LRectF | srcRect |
Subrect of the texture to be mapped in surface units. Coordinates should be specified in the space generated after applying the scale factor and transformation to the texture buffer. |
LSize | dstSize | Destination size of the source rect in surface units. |
LTransform | srcTransform |
Transform already applied to the texture. For example, if the texture is rotated 90 degrees counterclockwise and you want to display it in a normal orientation, use LTransform::Rotated90 and LPainter will apply the inverse transform (LTransform::Rotated270). |
Float32 | srcScale | Scale factor of the texture. |
|
noexcept |
Switches to texture mode.
This method maps a texture to the compositor-global space, enabling subsequent drawing of specific sub-rectangles using drawBox(), drawRect() or drawRegion().
params | Parameters required to map the texture. |
|
noexcept |
Switches to color mode.
In color mode, drawBox(), drawRect() and drawRegion() can be used to draw rectagles of the specified color.
The color is set using setColor() and setAlpha().
|
noexcept |
Draws a texture or color box on the screen based on the current rendering mode.
box | The box to be drawn in compositor-global coordinates. |
|
noexcept |
Draws a texture or color rect on the screen based on the current rendering mode.
rect | The rect to be drawn in compositor-global coordinates. |
|
noexcept |
Draws a texture or color region on the screen based on the current rendering mode.
region | The region to be drawn in compositor-global coordinates. |
|
noexcept |
Enables or disables a custom texture color.
When enabled, the bound texture RGB values are replaced by the color set with setColor().
|
noexcept |
Checks if custom texture color is enabled.
true
if custom texture color is enabled, otherwise false
.
|
noexcept |
Checks if automatic blending function selection is enabled.
|
noexcept |
Toggles automatic blending function selection.
When enabled, LPainter will automatically select the appropriate OpenGL blend function mode based on whether the bound texture uses premultiplied alpha or not (see LTexture::premultipliedAlpha()).
When disabled, LPainter will use the blend function set with setBlendFunc().
Enabled by default.
|
noexcept |
Sets a custom blend function.
Setting a custom blend function can be useful for masking or other sophisticated blending effects.
To make LPainter use this blend function, the auto blend function must be disabled, see enableAutoBlendFunc().
|
noexcept |
Sets the alpha value.
alpha | The alpha value to be set. |
|
noexcept |
Sets the color.
color | The color to be set. |
Sets the color factor.
This method multiplies each component of the source color by the specified factor.
r | The value of the red component (range: [0.0, 1.0]). |
g | The value of the green component (range: [0.0, 1.0]). |
b | The value of the blue component (range: [0.0, 1.0]). |
a | The value of the alpha component (range: [0.0, 1.0]). |
|
noexcept |
Sets the color factor.
This method multiplies each component of the source color by the specified factor.
factor | The color factor to be set. |
Sets the clear color.
This method sets the clear color used when calling clearScreen().
r | Value of the red component (range [0.0, 1.0]). |
g | Value of the green component (range [0.0, 1.0]). |
b | Value of the blue component (range [0.0, 1.0]). |
a | Value of the alpha component (range [0.0, 1.0]). |
|
noexcept |
Set the clear color.
This method sets the clear color used when calling clearScreen().
|
noexcept |
Clear the framebuffer.
This method clears the bound framebuffer using the color set with setClearColor().
|
noexcept |
Sets the viewport.
Sets the viewport.
|
noexcept |
Binds the specified framebuffer for rendering.
This method binds the provided framebuffer for rendering, allowing subsequent rendering operations to be performed on it.
framebuffer | The framebuffer to be bound. |
|
noexcept |
Retrieves the currently bound framebuffer.
This method returns a pointer to the currently bound framebuffer for rendering.