Vital
Loading...
Searching...
No Matches
OverlayBackgroundRenderer Class Reference

A component that renders a full-screen overlay background using OpenGL. More...

#include <overlay.h>

Inheritance diagram for OverlayBackgroundRenderer:
OpenGlComponent

Public Member Functions

 OverlayBackgroundRenderer ()
 Constructs an OverlayBackgroundRenderer with default settings.
 
virtual ~OverlayBackgroundRenderer ()
 Destructor.
 
virtual void init (OpenGlWrapper &open_gl) override
 Initializes the OpenGL shader and buffers.
 
virtual void render (OpenGlWrapper &open_gl, bool animate) override
 Renders the overlay using OpenGL.
 
void paintBackground (Graphics &g) override
 This overlay does not paint a background using JUCE's Graphics.
 
virtual void destroy (OpenGlWrapper &open_gl) override
 Destroys OpenGL resources allocated for this overlay.
 
void setColor (const Colour &color)
 Sets the overlay color.
 
force_inline void setAdditiveBlending (bool additive_blending)
 Enables or disables additive blending.
 
- Public Member Functions inherited from OpenGlComponent
 OpenGlComponent (String name="")
 Constructs an OpenGlComponent.
 
virtual ~OpenGlComponent ()
 Destructor.
 
virtual void resized () override
 Called when the component is resized.
 
virtual void parentHierarchyChanged () override
 Called when the component's parent hierarchy changes.
 
void addRoundedCorners ()
 Adds rounded corners to the component's edges.
 
void addBottomRoundedCorners ()
 Adds rounded corners only at the bottom of the component.
 
void renderCorners (OpenGlWrapper &open_gl, bool animate, Colour color, float rounding)
 Renders the corner shapes using the given color and rounding amount.
 
void renderCorners (OpenGlWrapper &open_gl, bool animate)
 Renders corners with default body color and rounding.
 
void repaintBackground ()
 Requests a repaint of the component's background on the OpenGL layer.
 
Colour getBodyColor () const
 Retrieves the component's body color.
 
void setParent (const SynthSection *parent)
 Sets a pointer to the parent SynthSection for skin value lookups.
 
float findValue (Skin::ValueId value_id)
 Finds a float value from the skin associated with this component's parent.
 
void setSkinValues (const Skin &skin)
 Applies the skin overrides to this component's colors.
 
void setSkinOverride (Skin::SectionOverride skin_override)
 Sets a skin override to control the component's color scheme.
 
force_inline void checkGlError ()
 Checks for and asserts that there are no OpenGL errors.
 
void setBackgroundColor (const Colour &color)
 Sets the background color of the component for painting operations.
 

Static Public Attributes

static constexpr int kNumVertices = 4
 Number of vertices for the overlay quad.
 
static constexpr int kNumFloatsPerVertex = 2
 Floats per vertex (x and y).
 
static constexpr int kTotalFloats = kNumVertices * kNumFloatsPerVertex
 Total floats for the quad (4 vertices * 2 floats).
 
static constexpr int kIndices = 6
 Number of indices (2 triangles * 3 indices).
 

Protected Member Functions

void drawOverlay (OpenGlWrapper &open_gl)
 Draws the overlay quad.
 
- Protected Member Functions inherited from OpenGlComponent
bool setViewPort (OpenGlWrapper &open_gl)
 Sets the viewport for this component using the current OpenGlWrapper.
 

Protected Attributes

OpenGLShaderProgram * shader_
 Shader program used for overlay drawing.
 
std::unique_ptr< OpenGLShaderProgram::Uniform > color_uniform_
 Uniform for overlay color.
 
std::unique_ptr< OpenGLShaderProgram::Attribute > position_
 Attribute for vertex positions.
 
Colour color_
 The overlay color.
 
bool additive_blending_
 Whether additive blending is enabled.
 
float data_ [kTotalFloats]
 Vertex data for the overlay quad.
 
int indices_ [kIndices]
 Index data for the overlay quad.
 
GLuint data_buffer_
 OpenGL buffer for vertex data.
 
GLuint indices_buffer_
 OpenGL buffer for index data.
 
- Protected Attributes inherited from OpenGlComponent
std::unique_ptr< OpenGlCornerscorners_
 Optional corners for rounded edges.
 
bool only_bottom_corners_
 Flag to round only the bottom corners.
 
Colour background_color_
 The background color of the component.
 
Colour body_color_
 The body color of the component.
 
const SynthSectionparent_
 Pointer to parent SynthSection for skin lookups.
 
Skin::SectionOverride skin_override_
 Skin override for custom appearance.
 
const vital::StatusOutputnum_voices_readout_
 StatusOutput for voice count lookups.
 

Additional Inherited Members

- Static Public Member Functions inherited from OpenGlComponent
static bool setViewPort (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
 Sets the OpenGL viewport to match a specified rectangle within a component.
 
static bool setViewPort (Component *component, OpenGlWrapper &open_gl)
 Convenience overload that sets the viewport for the entire component's local bounds.
 
static void setScissor (Component *component, OpenGlWrapper &open_gl)
 Sets the OpenGL scissor region to the entire component's local bounds.
 
static void setScissorBounds (Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
 Sets the OpenGL scissor region to a specified rectangle within a component.
 
static std::unique_ptr< OpenGLShaderProgram::Uniform > getUniform (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name)
 Retrieves a uniform from the shader program if it exists.
 
static std::unique_ptr< OpenGLShaderProgram::Attribute > getAttribute (const OpenGlWrapper &open_gl, const OpenGLShaderProgram &program, const char *name)
 Retrieves an attribute from the shader program if it exists.
 
static String translateFragmentShader (const String &code)
 Translates a fragment shader code snippet to be compatible with the current GL version.
 
static String translateVertexShader (const String &code)
 Translates a vertex shader code snippet to be compatible with the current GL version.
 

Detailed Description

A component that renders a full-screen overlay background using OpenGL.

The OverlayBackgroundRenderer draws a simple rectangular overlay covering its bounds, using a specified color and optional additive blending. It's designed to be used as the background layer for overlay components.

Constructor & Destructor Documentation

◆ OverlayBackgroundRenderer()

OverlayBackgroundRenderer::OverlayBackgroundRenderer ( )
inline

Constructs an OverlayBackgroundRenderer with default settings.

◆ ~OverlayBackgroundRenderer()

virtual OverlayBackgroundRenderer::~OverlayBackgroundRenderer ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ destroy()

virtual void OverlayBackgroundRenderer::destroy ( OpenGlWrapper & open_gl)
inlineoverridevirtual

Destroys OpenGL resources allocated for this overlay.

Parameters
open_glThe OpenGlWrapper with the OpenGL context.

Reimplemented from OpenGlComponent.

◆ drawOverlay()

void OverlayBackgroundRenderer::drawOverlay ( OpenGlWrapper & open_gl)
inlineprotected

Draws the overlay quad.

Parameters
open_glThe OpenGlWrapper with the current OpenGL context.

◆ init()

virtual void OverlayBackgroundRenderer::init ( OpenGlWrapper & open_gl)
inlineoverridevirtual

Initializes the OpenGL shader and buffers.

Parameters
open_glThe OpenGlWrapper providing the current OpenGL context.

Reimplemented from OpenGlComponent.

◆ paintBackground()

void OverlayBackgroundRenderer::paintBackground ( Graphics & g)
inlineoverridevirtual

This overlay does not paint a background using JUCE's Graphics.

Parameters
gThe graphics context.

Reimplemented from OpenGlComponent.

◆ render()

virtual void OverlayBackgroundRenderer::render ( OpenGlWrapper & open_gl,
bool animate )
inlineoverridevirtual

Renders the overlay using OpenGL.

Parameters
open_glThe OpenGlWrapper with the current OpenGL context.
animateWhether animations are enabled (not typically needed for a static overlay).

Implements OpenGlComponent.

◆ setAdditiveBlending()

force_inline void OverlayBackgroundRenderer::setAdditiveBlending ( bool additive_blending)
inline

Enables or disables additive blending.

Parameters
additive_blendingTrue for additive blending, false for normal blending.

◆ setColor()

void OverlayBackgroundRenderer::setColor ( const Colour & color)
inline

Sets the overlay color.

Parameters
colorThe new overlay color.

Member Data Documentation

◆ additive_blending_

bool OverlayBackgroundRenderer::additive_blending_
protected

Whether additive blending is enabled.

◆ color_

Colour OverlayBackgroundRenderer::color_
protected

The overlay color.

◆ color_uniform_

std::unique_ptr<OpenGLShaderProgram::Uniform> OverlayBackgroundRenderer::color_uniform_
protected

Uniform for overlay color.

◆ data_

float OverlayBackgroundRenderer::data_[kTotalFloats]
protected

Vertex data for the overlay quad.

◆ data_buffer_

GLuint OverlayBackgroundRenderer::data_buffer_
protected

OpenGL buffer for vertex data.

◆ indices_

int OverlayBackgroundRenderer::indices_[kIndices]
protected

Index data for the overlay quad.

◆ indices_buffer_

GLuint OverlayBackgroundRenderer::indices_buffer_
protected

OpenGL buffer for index data.

◆ kIndices

int OverlayBackgroundRenderer::kIndices = 6
staticconstexpr

Number of indices (2 triangles * 3 indices).

◆ kNumFloatsPerVertex

int OverlayBackgroundRenderer::kNumFloatsPerVertex = 2
staticconstexpr

Floats per vertex (x and y).

◆ kNumVertices

int OverlayBackgroundRenderer::kNumVertices = 4
staticconstexpr

Number of vertices for the overlay quad.

◆ kTotalFloats

int OverlayBackgroundRenderer::kTotalFloats = kNumVertices * kNumFloatsPerVertex
staticconstexpr

Total floats for the quad (4 vertices * 2 floats).

◆ position_

std::unique_ptr<OpenGLShaderProgram::Attribute> OverlayBackgroundRenderer::position_
protected

Attribute for vertex positions.

◆ shader_

OpenGLShaderProgram* OverlayBackgroundRenderer::shader_
protected

Shader program used for overlay drawing.


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