44 setInterceptsMouseClicks(
false,
false);
60 GLsizeiptr vert_size =
static_cast<GLsizeiptr
>(
kTotalFloats *
sizeof(float));
61 open_gl.
context.extensions.glBufferData(GL_ARRAY_BUFFER, vert_size,
data_, GL_STATIC_DRAW);
66 GLsizeiptr bar_size =
static_cast<GLsizeiptr
>(
kIndices *
sizeof(int));
67 open_gl.
context.extensions.glBufferData(GL_ELEMENT_ARRAY_BUFFER, bar_size,
indices_, GL_STATIC_DRAW);
130 glEnable(GL_SCISSOR_TEST);
132 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
134 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
145 open_gl.
context.extensions.glEnableVertexAttribArray(
position_->attributeID);
147 glDrawElements(GL_TRIANGLES,
kIndices, GL_UNSIGNED_INT,
nullptr);
149 open_gl.
context.extensions.glDisableVertexAttribArray(
position_->attributeID);
150 open_gl.
context.extensions.glBindBuffer(GL_ARRAY_BUFFER, 0);
151 open_gl.
context.extensions.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
154 glDisable(GL_SCISSOR_TEST);
159 std::unique_ptr<OpenGLShaderProgram::Attribute>
position_;
203 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
Listener)
226 if (should_be_visible)
227 listener->overlayShown(
this);
229 listener->overlayHidden(
this);
231 Component::setVisible(should_be_visible);
271 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
Overlay)
A base component class that integrates JUCE's Component with OpenGL rendering.
Definition open_gl_component.h:20
static bool setViewPort(Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
Sets the OpenGL viewport to match a specified rectangle within a component.
Definition open_gl_component.cpp:42
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.
Definition open_gl_component.h:79
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.
Definition open_gl_component.h:64
Interface for receiving notifications about overlay visibility changes.
Definition overlay.h:186
virtual void overlayHidden(Overlay *component)=0
Called when the overlay is hidden.
virtual ~Listener()
Definition overlay.h:189
Listener()
Definition overlay.h:188
virtual void overlayShown(Overlay *component)=0
Called when the overlay is shown.
A component that renders a full-screen overlay background using OpenGL.
Definition overlay.h:16
OpenGLShaderProgram * shader_
Shader program used for overlay drawing.
Definition overlay.h:157
virtual void init(OpenGlWrapper &open_gl) override
Initializes the OpenGL shader and buffers.
Definition overlay.h:56
std::unique_ptr< OpenGLShaderProgram::Attribute > position_
Attribute for vertex positions.
Definition overlay.h:159
void setColor(const Colour &color)
Sets the overlay color.
Definition overlay.h:109
virtual void destroy(OpenGlWrapper &open_gl) override
Destroys OpenGL resources allocated for this overlay.
Definition overlay.h:94
int indices_[kIndices]
Index data for the overlay quad.
Definition overlay.h:165
OverlayBackgroundRenderer()
Constructs an OverlayBackgroundRenderer with default settings.
Definition overlay.h:30
GLuint indices_buffer_
OpenGL buffer for index data.
Definition overlay.h:167
static constexpr int kNumFloatsPerVertex
Floats per vertex (x and y).
Definition overlay.h:21
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the overlay using OpenGL.
Definition overlay.h:80
virtual ~OverlayBackgroundRenderer()
Destructor.
Definition overlay.h:50
float data_[kTotalFloats]
Vertex data for the overlay quad.
Definition overlay.h:164
std::unique_ptr< OpenGLShaderProgram::Uniform > color_uniform_
Uniform for overlay color.
Definition overlay.h:158
Colour color_
The overlay color.
Definition overlay.h:161
bool additive_blending_
Whether additive blending is enabled.
Definition overlay.h:162
force_inline void setAdditiveBlending(bool additive_blending)
Enables or disables additive blending.
Definition overlay.h:115
static constexpr int kTotalFloats
Total floats for the quad (4 vertices * 2 floats).
Definition overlay.h:23
static constexpr int kIndices
Number of indices (2 triangles * 3 indices).
Definition overlay.h:25
void drawOverlay(OpenGlWrapper &open_gl)
Draws the overlay quad.
Definition overlay.h:122
GLuint data_buffer_
OpenGL buffer for vertex data.
Definition overlay.h:166
static constexpr int kNumVertices
Number of vertices for the overlay quad.
Definition overlay.h:19
void paintBackground(Graphics &g) override
This overlay does not paint a background using JUCE's Graphics.
Definition overlay.h:88
A SynthSection that displays an overlay with a background and optional listeners.
Definition overlay.h:180
Overlay(String name)
Constructs an Overlay with a given name.
Definition overlay.h:210
virtual void paintBackground(Graphics &g) override
Paints the background using OpenGL-rendered children.
Definition overlay.h:246
void addOverlayListener(Listener *listener)
Adds a listener to be notified of overlay visibility changes.
Definition overlay.h:252
void removeOverlayListener(Listener *listener)
Removes a previously added overlay listener.
Definition overlay.h:258
std::set< Listener * > listeners_
Registered overlay listeners.
Definition overlay.h:268
virtual void resized() override
Called when the overlay is resized. Updates background color and size.
Definition overlay.h:237
virtual ~Overlay()
Destructor.
Definition overlay.h:218
void setSizeRatio(float ratio) override
Sets the size ratio for the overlay, used in some layouts.
Definition overlay.h:264
void setVisible(bool should_be_visible) override
Sets the visibility of the overlay and notifies listeners.
Definition overlay.h:224
float size_ratio_
A scaling factor for the overlay size.
Definition overlay.h:267
OverlayBackgroundRenderer background_
Renders the overlay background.
Definition overlay.h:269
@ kPassthroughVertex
Definition shaders.h:29
@ kColorFragment
Definition shaders.h:63
OpenGLShaderProgram * getShaderProgram(VertexShader vertex_shader, FragmentShader fragment_shader, const GLchar **varyings=nullptr)
Retrieves or creates an OpenGLShaderProgram from a given vertex and fragment shader pair.
Definition shaders.cpp:953
@ kOverlayScreen
Definition skin.h:140
@ kOverlay
Definition skin.h:34
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
void paintOpenGlChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all OpenGL child components.
Definition synth_section.cpp:267
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
#define force_inline
Definition common.h:23
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
OpenGLContext & context
The OpenGLContext for current rendering.
Definition shaders.h:181
Shaders * shaders
Pointer to the Shaders instance providing compiled shaders.
Definition shaders.h:182