Vital
Loading...
Searching...
No Matches
peak_meter_viewer.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4#include "open_gl_component.h"
5#include "synth_module.h"
6
16public:
21 PeakMeterViewer(bool left);
22
26 virtual ~PeakMeterViewer();
27
31 void resized() override;
32
37 void init(OpenGlWrapper& open_gl) override;
38
44 void render(OpenGlWrapper& open_gl, bool animate) override;
45
50 void draw(OpenGlWrapper& open_gl);
51
56 void destroy(OpenGlWrapper& open_gl) override;
57
62 void paintBackground(Graphics& g) override;
63
64private:
68 void updateVertices();
69
73 void updateVerticesMemory();
74
75 static constexpr int kNumPositions = 8;
76 static constexpr int kNumTriangleIndices = 6;
77
78 const vital::StatusOutput* peak_output_;
79 const vital::StatusOutput* peak_memory_output_;
80
81 OpenGLShaderProgram* shader_;
82 std::unique_ptr<OpenGLShaderProgram::Attribute> position_;
83 std::unique_ptr<OpenGLShaderProgram::Uniform> color_from_;
84 std::unique_ptr<OpenGLShaderProgram::Uniform> color_to_;
85
86 float clamped_;
87 float position_vertices_[kNumPositions];
88 int position_triangles_[kNumTriangleIndices];
89 GLuint vertex_buffer_;
90 GLuint triangle_buffer_;
91 bool left_;
92
93 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PeakMeterViewer)
94};
A base component class that integrates JUCE's Component with OpenGL rendering.
Definition open_gl_component.h:20
A visual component to display a peak meter using OpenGL.
Definition peak_meter_viewer.h:15
void init(OpenGlWrapper &open_gl) override
Initializes the OpenGL buffers and shader for drawing the meter.
Definition peak_meter_viewer.cpp:48
void paintBackground(Graphics &g) override
Paints a background for the meter, showing ranges or thresholds.
Definition peak_meter_viewer.cpp:174
void render(OpenGlWrapper &open_gl, bool animate) override
Renders the peak meter using OpenGL.
Definition peak_meter_viewer.cpp:109
void resized() override
Called when the component is resized. Initializes status outputs if needed.
Definition peak_meter_viewer.cpp:38
void draw(OpenGlWrapper &open_gl)
Draws the peak meter quads according to current peak and memory values.
Definition peak_meter_viewer.cpp:145
void destroy(OpenGlWrapper &open_gl) override
Releases any OpenGL resources associated with this component.
Definition peak_meter_viewer.cpp:163
PeakMeterViewer(bool left)
Constructs a PeakMeterViewer.
Definition peak_meter_viewer.cpp:14
virtual ~PeakMeterViewer()
Destructor.
Definition peak_meter_viewer.cpp:36
A helper class to track the "status" of a particular Output as a poly_float value.
Definition synth_module.h:35
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
Defines the SynthModule class which extends ProcessorRouter to form a building block of the Vital syn...