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

A component for rendering lines with optional filling and boost effects using OpenGL. More...

#include <open_gl_line_renderer.h>

Inheritance diagram for OpenGlLineRenderer:
OpenGlComponent DelayFilterViewer DistortionFilterResponse DistortionViewer EnvelopeEditor EqualizerResponse FilterResponse FlangerResponse LineEditor Oscilloscope PhaserResponse RandomViewer SampleViewer Spectrogram WaveSourceEditor WaveWindowEditor

Public Member Functions

 OpenGlLineRenderer (int num_points, bool loop=false)
 Constructs an OpenGlLineRenderer for a given number of points.
 
virtual ~OpenGlLineRenderer ()
 Destructor.
 
virtual void init (OpenGlWrapper &open_gl) override
 Initializes OpenGL resources for rendering the line.
 
virtual void render (OpenGlWrapper &open_gl, bool animate) override
 Renders the line using OpenGL.
 
virtual void destroy (OpenGlWrapper &open_gl) override
 Destroys OpenGL resources allocated by this line renderer.
 
force_inline void setColor (Colour color)
 Sets the line color.
 
force_inline void setLineWidth (float width)
 Sets the line width in pixels.
 
force_inline void setBoost (float boost)
 Sets a global boost value affecting line thickness.
 
force_inline float boostLeftAt (int index) const
 Gets the left-side boost at a given point index.
 
force_inline float boostRightAt (int index) const
 Gets the right-side boost at a given point index.
 
force_inline float yAt (int index) const
 Gets the y-coordinate of a point at a given index.
 
force_inline float xAt (int index) const
 Gets the x-coordinate of a point at a given index.
 
force_inline void setBoostLeft (int index, float val)
 Sets the left-side boost for a point, marking data as dirty.
 
force_inline void setBoostRight (int index, float val)
 Sets the right-side boost for a point, marking data as dirty.
 
force_inline void setYAt (int index, float val)
 Sets the y-coordinate of a point, marking data as dirty.
 
force_inline void setXAt (int index, float val)
 Sets the x-coordinate of a point, marking data as dirty.
 
void setFillVertices (bool left)
 Sets fill vertices according to the current line and boost data.
 
void setLineVertices (bool left)
 Sets line vertices according to the current line and boost data.
 
force_inline void setFill (bool fill)
 Enables or disables filling below the line.
 
force_inline void setFillColor (Colour fill_color)
 Sets a uniform fill color if only one color is needed.
 
force_inline void setFillColors (Colour fill_color_from, Colour fill_color_to)
 Sets a gradient fill from one color to another.
 
force_inline void setFillCenter (float fill_center)
 Sets the vertical center for the fill area.
 
force_inline void setFit (bool fit)
 Enables fitting the line inside the available area.
 
force_inline void setBoostAmount (float boost_amount)
 Sets the boost amount that affects line thickness.
 
force_inline void setFillBoostAmount (float boost_amount)
 Sets the boost amount that affects fill thickness.
 
force_inline void setIndex (int index)
 Sets an index used for custom behavior (e.g., multiple line sets).
 
void boostLeftRange (float start, float end, int buffer_vertices, float min)
 Boosts left-side range of the line.
 
void boostRightRange (float start, float end, int buffer_vertices, float min)
 Boosts right-side range of the line.
 
void boostRange (float *boosts, float start, float end, int buffer_vertices, float min)
 Boosts a range for the given boost array.
 
void boostRange (vital::poly_float start, vital::poly_float end, int buffer_vertices, vital::poly_float min)
 Boosts left and right arrays using poly_float parameters.
 
void decayBoosts (vital::poly_float mult)
 Decays all boosts by a multiplicative factor, allowing animated damping.
 
void enableBackwardBoost (bool enable)
 Enables backward boost calculation for symmetrical line deformation.
 
force_inline int numPoints () const
 Gets the number of points in the line.
 
force_inline Colour color () const
 Gets the current line color.
 
void drawLines (OpenGlWrapper &open_gl, bool left)
 Draws the line and optional fill using OpenGL.
 
bool anyBoostValue ()
 Checks if any boost value is set.
 
- 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.
 
virtual void paintBackground (Graphics &g)
 Paints a standard background for the component.
 
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 kLineFloatsPerVertex = 3
 Floats per vertex in the line data (x, y, and potentially others).
 
static constexpr int kFillFloatsPerVertex = 4
 Floats per vertex in the fill data (x, y, and boost value).
 
static constexpr int kLineVerticesPerPoint = 6
 Number of vertices per point in the line representation.
 
static constexpr int kFillVerticesPerPoint = 2
 Number of vertices per point in the fill representation.
 
static constexpr int kLineFloatsPerPoint = kLineVerticesPerPoint * kLineFloatsPerVertex
 Floats per point in the line data (6 vertices * 3 floats each).
 
static constexpr int kFillFloatsPerPoint = kFillVerticesPerPoint * kFillFloatsPerVertex
 Floats per point in the fill data (2 vertices * 4 floats each).
 

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.
 
- Protected Member Functions inherited from OpenGlComponent
bool setViewPort (OpenGlWrapper &open_gl)
 Sets the viewport for this component using the current OpenGlWrapper.
 
- 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.
 

Detailed Description

A component for rendering lines with optional filling and boost effects using OpenGL.

The OpenGlLineRenderer class takes a set of points and renders them as a smooth line using OpenGL, optionally adding fill and adjustable "boost" effects to create animated line deformations. It supports looping lines, color customization, and variable line widths.

Constructor & Destructor Documentation

◆ OpenGlLineRenderer()

OpenGlLineRenderer::OpenGlLineRenderer ( int num_points,
bool loop = false )

Constructs an OpenGlLineRenderer for a given number of points.

Parameters
num_pointsThe number of points in the line.
loopIf true, the line is treated as looping (connects end-to-start).

◆ ~OpenGlLineRenderer()

OpenGlLineRenderer::~OpenGlLineRenderer ( )
virtual

Destructor.

Member Function Documentation

◆ anyBoostValue()

bool OpenGlLineRenderer::anyBoostValue ( )
inline

Checks if any boost value is set.

Returns
True if there's any non-zero boost, otherwise false.

◆ boostLeftAt()

force_inline float OpenGlLineRenderer::boostLeftAt ( int index) const
inline

Gets the left-side boost at a given point index.

◆ boostLeftRange()

void OpenGlLineRenderer::boostLeftRange ( float start,
float end,
int buffer_vertices,
float min )

Boosts left-side range of the line.

Parameters
startThe normalized start position in [0, 1].
endThe normalized end position in [0, 1].
buffer_verticesHow many vertices to skip at start/end (padding).
minThe minimum boost value.

◆ boostRange() [1/2]

void OpenGlLineRenderer::boostRange ( float * boosts,
float start,
float end,
int buffer_vertices,
float min )

Boosts a range for the given boost array.

◆ boostRange() [2/2]

void OpenGlLineRenderer::boostRange ( vital::poly_float start,
vital::poly_float end,
int buffer_vertices,
vital::poly_float min )

Boosts left and right arrays using poly_float parameters.

◆ boostRightAt()

force_inline float OpenGlLineRenderer::boostRightAt ( int index) const
inline

Gets the right-side boost at a given point index.

◆ boostRightRange()

void OpenGlLineRenderer::boostRightRange ( float start,
float end,
int buffer_vertices,
float min )

Boosts right-side range of the line.

◆ color()

force_inline Colour OpenGlLineRenderer::color ( ) const
inline

Gets the current line color.

◆ decayBoosts()

void OpenGlLineRenderer::decayBoosts ( vital::poly_float mult)

Decays all boosts by a multiplicative factor, allowing animated damping.

Parameters
multThe multiplicative factor to decay the boosts by.

◆ destroy()

void OpenGlLineRenderer::destroy ( OpenGlWrapper & open_gl)
overridevirtual

Destroys OpenGL resources allocated by this line renderer.

Parameters
open_glThe OpenGlWrapper providing the OpenGL context.

Reimplemented from OpenGlComponent.

Reimplemented in DistortionFilterResponse, EnvelopeEditor, EqualizerResponse, FilterResponse, FlangerResponse, LineEditor, PhaserResponse, RandomViewer, SampleViewer, WaveSourceEditor, and WaveWindowEditor.

◆ drawLines()

void OpenGlLineRenderer::drawLines ( OpenGlWrapper & open_gl,
bool left )

Draws the line and optional fill using OpenGL.

Parameters
open_glThe OpenGlWrapper with the current OpenGL context.
leftIf true, uses left-side boosts; otherwise right-side.

◆ enableBackwardBoost()

void OpenGlLineRenderer::enableBackwardBoost ( bool enable)
inline

Enables backward boost calculation for symmetrical line deformation.

◆ init()

void OpenGlLineRenderer::init ( OpenGlWrapper & open_gl)
overridevirtual

Initializes OpenGL resources for rendering the line.

Parameters
open_glThe OpenGlWrapper providing the OpenGL context.

Reimplemented from OpenGlComponent.

Reimplemented in DistortionFilterResponse, EnvelopeEditor, EqualizerResponse, FilterResponse, FlangerResponse, LineEditor, PhaserResponse, RandomViewer, SampleViewer, WaveSourceEditor, and WaveWindowEditor.

◆ numPoints()

force_inline int OpenGlLineRenderer::numPoints ( ) const
inline

Gets the number of points in the line.

◆ render()

void OpenGlLineRenderer::render ( OpenGlWrapper & open_gl,
bool animate )
overridevirtual

Renders the line using OpenGL.

Parameters
open_glThe OpenGlWrapper providing the OpenGL context.
animateIf true, animations (like boosts) are allowed.

Implements OpenGlComponent.

Reimplemented in DelayFilterViewer, DistortionFilterResponse, DistortionViewer, EnvelopeEditor, EqualizerResponse, FilterResponse, FlangerResponse, LfoEditor, LineEditor, LineMapEditor, Oscilloscope, PhaserResponse, RandomViewer, SampleViewer, Spectrogram, WaveSourceEditor, and WaveWindowEditor.

◆ setBoost()

force_inline void OpenGlLineRenderer::setBoost ( float boost)
inline

Sets a global boost value affecting line thickness.

◆ setBoostAmount()

force_inline void OpenGlLineRenderer::setBoostAmount ( float boost_amount)
inline

Sets the boost amount that affects line thickness.

◆ setBoostLeft()

force_inline void OpenGlLineRenderer::setBoostLeft ( int index,
float val )
inline

Sets the left-side boost for a point, marking data as dirty.

◆ setBoostRight()

force_inline void OpenGlLineRenderer::setBoostRight ( int index,
float val )
inline

Sets the right-side boost for a point, marking data as dirty.

◆ setColor()

force_inline void OpenGlLineRenderer::setColor ( Colour color)
inline

Sets the line color.

◆ setFill()

force_inline void OpenGlLineRenderer::setFill ( bool fill)
inline

Enables or disables filling below the line.

◆ setFillBoostAmount()

force_inline void OpenGlLineRenderer::setFillBoostAmount ( float boost_amount)
inline

Sets the boost amount that affects fill thickness.

◆ setFillCenter()

force_inline void OpenGlLineRenderer::setFillCenter ( float fill_center)
inline

Sets the vertical center for the fill area.

◆ setFillColor()

force_inline void OpenGlLineRenderer::setFillColor ( Colour fill_color)
inline

Sets a uniform fill color if only one color is needed.

◆ setFillColors()

force_inline void OpenGlLineRenderer::setFillColors ( Colour fill_color_from,
Colour fill_color_to )
inline

Sets a gradient fill from one color to another.

◆ setFillVertices()

void OpenGlLineRenderer::setFillVertices ( bool left)

Sets fill vertices according to the current line and boost data.

Parameters
leftIf true, sets vertices based on left-side boosting, otherwise right side.

◆ setFit()

force_inline void OpenGlLineRenderer::setFit ( bool fit)
inline

Enables fitting the line inside the available area.

◆ setIndex()

force_inline void OpenGlLineRenderer::setIndex ( int index)
inline

Sets an index used for custom behavior (e.g., multiple line sets).

◆ setLineVertices()

void OpenGlLineRenderer::setLineVertices ( bool left)

Sets line vertices according to the current line and boost data.

Parameters
leftIf true, sets vertices based on left-side boosting, otherwise right side.

◆ setLineWidth()

force_inline void OpenGlLineRenderer::setLineWidth ( float width)
inline

Sets the line width in pixels.

◆ setXAt()

force_inline void OpenGlLineRenderer::setXAt ( int index,
float val )
inline

Sets the x-coordinate of a point, marking data as dirty.

◆ setYAt()

force_inline void OpenGlLineRenderer::setYAt ( int index,
float val )
inline

Sets the y-coordinate of a point, marking data as dirty.

◆ xAt()

force_inline float OpenGlLineRenderer::xAt ( int index) const
inline

Gets the x-coordinate of a point at a given index.

◆ yAt()

force_inline float OpenGlLineRenderer::yAt ( int index) const
inline

Gets the y-coordinate of a point at a given index.

Member Data Documentation

◆ kFillFloatsPerPoint

int OpenGlLineRenderer::kFillFloatsPerPoint = kFillVerticesPerPoint * kFillFloatsPerVertex
staticconstexpr

Floats per point in the fill data (2 vertices * 4 floats each).

◆ kFillFloatsPerVertex

int OpenGlLineRenderer::kFillFloatsPerVertex = 4
staticconstexpr

Floats per vertex in the fill data (x, y, and boost value).

◆ kFillVerticesPerPoint

int OpenGlLineRenderer::kFillVerticesPerPoint = 2
staticconstexpr

Number of vertices per point in the fill representation.

◆ kLineFloatsPerPoint

int OpenGlLineRenderer::kLineFloatsPerPoint = kLineVerticesPerPoint * kLineFloatsPerVertex
staticconstexpr

Floats per point in the line data (6 vertices * 3 floats each).

◆ kLineFloatsPerVertex

int OpenGlLineRenderer::kLineFloatsPerVertex = 3
staticconstexpr

Floats per vertex in the line data (x, y, and potentially others).

◆ kLineVerticesPerPoint

int OpenGlLineRenderer::kLineVerticesPerPoint = 6
staticconstexpr

Number of vertices per point in the line representation.


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