Rendering OpenGL subcomponents with Direct2D rendering disabled causes plugin windows to become completely transparent in some DAWs. When Direct2D rendering is enabled, certain elements on the OpenGL subcomponent such as text are not rendered. This issue is introduced by commit 340f531
and does not occur when the plugin editor is attached to an OpenGL context rather than a subcomponent.
Here are some images demonstrating the issue on Windows 11 with scaling set to 100%. These images were taken in Studio One 6 (latest version), though the problem also appears in other DAWs I’ve tested.
Latest JUCE 8 Develop (D2D disabled):
Plugin window is completely transparent.
Latest JUCE 8 Develop (D2D enabled):
Background is painted but text is not.
JUCE 8 Develop prior to commit 340f531:
Here is the code I used to reproduce the issue shown in the first image:
PluginEditor.h:
#pragma once
#include <JuceHeader.h>
#include "PluginProcessor.h"
struct TestComponent : public juce::Component
{
public:
TestComponent()
{
m_openGLContext.attachTo(*this);
}
void paint(juce::Graphics& g) override
{
g.fillAll(juce::Colours::black);
g.setColour (juce::Colours::white);
g.setFont (juce::FontOptions (15.0f));
g.drawFittedText ("Testing", getLocalBounds(), juce::Justification::centred, 1);
}
private:
juce::OpenGLContext m_openGLContext;
};
//==============================================================================
/**
*/
class TestOpenGLAudioProcessorEditor : public juce::AudioProcessorEditor
{
public:
TestOpenGLAudioProcessorEditor (TestOpenGLAudioProcessor&);
~TestOpenGLAudioProcessorEditor() override;
//==============================================================================
void paint (juce::Graphics&) override;
void resized() override;
void parentHierarchyChanged() override
{
if (auto peer = getPeer())
{
peer->setCurrentRenderingEngine(0);
}
}
private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
TestOpenGLAudioProcessor& audioProcessor;
TestComponent m_glComponent;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TestOpenGLAudioProcessorEditor)
};
PluginEditor.cpp:
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
TestOpenGLAudioProcessorEditor::TestOpenGLAudioProcessorEditor (TestOpenGLAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
addAndMakeVisible(m_glComponent);
setSize (300, 180);
}
TestOpenGLAudioProcessorEditor::~TestOpenGLAudioProcessorEditor()
{
}
//==============================================================================
void TestOpenGLAudioProcessorEditor::paint (juce::Graphics& g)
{
}
void TestOpenGLAudioProcessorEditor::resized()
{
m_glComponent.setBounds(this->getBounds());
}
Here is the specific commit causing this issue: