Skip to content

Commit 278684c

Browse files
committed
gui: add chrome overlay support to ImpulseResponseDisplay
1 parent 72c1a56 commit 278684c

2 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/dmt/gui/display/DisfluxDisplay.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,11 @@ class alignas(64) DisfluxDisplay : public dmt::gui::display::MultiDisplay
6161
_apvts,
6262
[&] {
6363
std::vector<std::unique_ptr<AbstractDisplay>> displays;
64+
displays.push_back(std::make_unique<HelloWorldDisplay>());
6465
displays.push_back(
65-
std::make_unique<HelloWorldDisplay>());
66-
displays.push_back(
67-
std::make_unique<ImpulseResponseDisplay>());
68-
displays.push_back(
69-
std::make_unique<OscilloscopeDisplay<float>>(_fifoBuffer,
70-
_apvts,
71-
true));
66+
std::make_unique<ImpulseResponseDisplay>(getChromeOverlay()));
67+
displays.push_back(std::make_unique<OscilloscopeDisplay<float>>(
68+
_fifoBuffer, _apvts, true));
7269
return displays;
7370
}(),
7471
{ { "dis1uxFrequency", "ImpulseResponsePhaseRotationDisplay" } })

src/dmt/gui/display/ImpulseResponseDisplay.h

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ class ImpulseResponseDisplay
2929
using Settings = dmt::Settings;
3030
using Fonts = dmt::utility::Fonts;
3131
using Colour = juce::Colour;
32+
using Image = juce::Image;
3233

3334
public:
34-
explicit ImpulseResponseDisplay()
35+
explicit ImpulseResponseDisplay(const Image& _chromeOverlay)
3536
: AbstractDisplay()
3637
, label("Impulse Response", fonts.bold, rawFontSize, juce::Colours::white)
38+
, chromeOverlay(_chromeOverlay)
3739
{
3840
// addAndMakeVisible(label);
3941
openGLContext.setRenderer(this);
@@ -63,25 +65,18 @@ class ImpulseResponseDisplay
6365
void renderOpenGL() override
6466
{
6567
juce::OpenGLHelpers::clear(juce::Colours::black);
66-
6768
juce::OpenGLContext::getCurrentContext()->extensions.glUseProgram(
6869
shaderProgram->getProgramID());
69-
7070
auto& gl = openGLContext.extensions;
71-
7271
gl.glEnableVertexAttribArray(positionAttributeID);
73-
7472
gl.glBindBuffer(juce::gl::GL_ARRAY_BUFFER, vbo);
75-
7673
gl.glVertexAttribPointer(positionAttributeID,
7774
2,
7875
juce::gl::GL_FLOAT,
7976
juce::gl::GL_FALSE,
8077
sizeof(float) * 2,
8178
nullptr);
82-
8379
juce::gl::glDrawArrays(juce::gl::GL_TRIANGLES, 0, 3);
84-
8580
gl.glDisableVertexAttribArray(positionAttributeID);
8681
}
8782

@@ -93,7 +88,13 @@ class ImpulseResponseDisplay
9388
_g.setColour(juce::Colours::cyan);
9489
_g.drawRect(getLocalBounds(), 1);
9590
}
96-
_g.fillAll(juce::Colours::cyan);
91+
92+
// Draw the chrome overlay on top of the OpenGL content
93+
const int w1 = this->getWidth();
94+
const int w2 = chromeOverlay.getWidth();
95+
_g.drawImage(chromeOverlay,
96+
getLocalBounds().toFloat(),
97+
juce::RectanglePlacement::centred);
9798
}
9899

99100
void openGLContextClosing() override
@@ -103,11 +104,9 @@ class ImpulseResponseDisplay
103104
gl.glDeleteBuffers(1, &vbo);
104105
}
105106

106-
private:
107-
juce::OpenGLContext openGLContext;
108-
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgram;
109-
int positionAttributeID = -1;
110-
GLuint vbo = 0;
107+
void getChromeOverlay(Image& _overlay) { _overlay = chromeOverlay; }
108+
109+
protected:
111110
void createTriangle()
112111
{
113112
float vertices[] = { -0.5f, -0.5f, 0.5f, -0.5f, 0.0f, 0.5f };
@@ -139,10 +138,19 @@ class ImpulseResponseDisplay
139138
}
140139
)";
141140

141+
private:
142142
Label label;
143143
Fonts fonts;
144144
float rawFontSize = 24.0f;
145145

146+
const Image& chromeOverlay;
147+
148+
juce::OpenGLContext openGLContext;
149+
std::unique_ptr<juce::OpenGLShaderProgram> shaderProgram;
150+
int positionAttributeID = -1;
151+
GLuint vbo = 0;
152+
153+
//==============================================================================
146154
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImpulseResponseDisplay)
147155
};
148156
} // namespace display

0 commit comments

Comments
 (0)