# \[Bug\] OpenGL rendering issues with latest JUCE 8 develop on Windows

**URL:** <https://forum.juce.com/t/bug-opengl-rendering-issues-with-latest-juce-8-develop-on-windows/62599>\
**Category:** Windows\
**Created:** [August 23, 2024, 10:13pm UTC](https://forum.juce.com/t/bug-opengl-rendering-issues-with-latest-juce-8-develop-on-windows/62599 "2024-08-23T22:13:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![psyDSP](https://avatars.discourse-cdn.com/v4/letter/p/f04885/32.png) [@psyDSP](https://forum.juce.com/u/psyDSP)\
**Post date:** [August 23, 2024, 10:13pm UTC](https://forum.juce.com/t/bug-opengl-rendering-issues-with-latest-juce-8-develop-on-windows/62599/1 "2024-08-23T22:13:38Z")

</div>

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.  
 ![bug-juce-8-d2d-disabled](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/b/f/bfa6637554a2bcd2b6b3818a85e6dbda7ff2da4b.png)

**Latest JUCE 8 Develop (D2D enabled):**  
Background is painted but text is not.  
 ![bug-juce-8-d2d-enabled](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/f/2/f22ae842538d356f124cec58da7562dfee0b0235.png)

**JUCE 8 Develop prior to commit 340f531:**  
 ![juce-8-working](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/1/7/1769ec46a16d652b58ae33f00b188ecdebfcd225.png)

Here is the code I used to reproduce the issue shown in the first image:  
**PluginEditor.h:**

```auto
#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:**

```auto
#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:

> <https://github.com/juce-framework/JUCE/commit/340f531c71ebc62979e8c5ae9f18df26bf43a2d8>

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [September 5, 2024, 12:23pm UTC](https://forum.juce.com/t/bug-opengl-rendering-issues-with-latest-juce-8-develop-on-windows/62599/2 "2024-09-05T12:23:43Z")

</div>

Thanks for reporting. This issue should be resolved on the develop branch:

> <https://github.com/juce-framework/JUCE/commit/735f99418ccca5b0e50902ef9900b057aa16d39a>
>
> This fixes an issue introduced in
> 340f531c71ebc62979e8c5ae9f18df26bf43a2d8 where… embedded OpenGL windows
> would incorrectly have the WS\_EX\_LAYERED style bit set, which in turn
> prevented them from displaying correctly.
> 
> Before the window-transparency refactoring, OpenGL windows would not
> have the layered bit set because only peers with windowIsSemiTransparent
> were created with the layered bit, and the layered bit was only updated
> if the peer alpha was changed.
> 
> The new behaviour is to always set WS\_EX\_LAYERED if the peer's component
> is non-opaque with no titlebar, or if the component has an alpha \< 1.0f.
> The OpenGLContext's placeholder component has no titlebar, so it must be
> opaque in order to avoid setting the layered style bit.
