#ifndef TRANSPARENTOPENGLCOMPONENT_H_INCLUDED #define TRANSPARENTOPENGLCOMPONENT_H_INCLUDED #include "JuceHeader.h" // A Component with an attached OpenGLContext which saves the background under it, // and within the OpenGL context draws the background first, and then calls // its subclass's renderOverBackground method to draw. // // Assumptions: // * The background is constant. // * This component, its parent, and ancestors, do not have overlapping sibling components. class TransparentOpenGLComponent : public juce::Component, public juce::OpenGLRenderer { public: TransparentOpenGLComponent(); virtual ~TransparentOpenGLComponent(); virtual void renderOverBackground (juce::Point viewportSize) = 0; // Sub-classes overriding this must call these in their overrides. void newOpenGLContextCreated() override; void openGLContextClosing() override; juce::OpenGLContext openGLContext; protected: juce::Image renderBackground(); private: void renderOpenGL() override; void renderParentsToBackground (juce::Graphics& g, juce::Component&); juce::Point viewportSize; juce::OpenGLTexture backgroundTexture; }; #endif // TRANSPARENTOPENGLCOMPONENT_H_INCLUDED