2025-04-26 19:30:10 +00:00
|
|
|
#pragma once
|
|
|
|
#include <JuceHeader.h>
|
|
|
|
|
|
|
|
// An invisible component that owns a persistent OpenGL context, always attached to the desktop.
|
|
|
|
class InvisibleOpenGLContextComponent : public juce::Component {
|
|
|
|
public:
|
2025-05-04 21:29:08 +00:00
|
|
|
InvisibleOpenGLContextComponent(juce::OpenGLRenderer* renderer) {
|
2025-04-26 19:30:10 +00:00
|
|
|
setSize(1, 1); // Minimal size
|
|
|
|
setBounds(0, 0, 1, 1); // Minimal bounds
|
|
|
|
setVisible(true);
|
|
|
|
setOpaque(false);
|
|
|
|
context.setComponentPaintingEnabled(false);
|
2025-05-04 21:29:08 +00:00
|
|
|
context.setRenderer(renderer);
|
|
|
|
context.setContinuousRepainting(true);
|
2025-04-26 19:30:10 +00:00
|
|
|
context.attachTo(*this);
|
|
|
|
addToDesktop(
|
|
|
|
juce::ComponentPeer::windowIsTemporary |
|
|
|
|
juce::ComponentPeer::windowIgnoresKeyPresses |
|
|
|
|
juce::ComponentPeer::windowIgnoresMouseClicks
|
|
|
|
);
|
|
|
|
}
|
|
|
|
~InvisibleOpenGLContextComponent() override {
|
|
|
|
context.detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
juce::OpenGLContext& getContext() { return context; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
juce::OpenGLContext context;
|
|
|
|
};
|