OpenGLTexture::release() Assert


#1

I have a very simple app that is displaying an image in an OpenGLRenderer object. I get an assert on destroying the component and was hoping someone could tell me what I was doing wrong.
The assertion is in JUCE Assertion failure in opengl/juce_OpenGLTexture.cpp:164.

This is the class which will cause an assertion when deleting this component

class OGLTestComponent : public OpenGLRenderer, public Component
{
public:

	OGLTestComponent() {
		context.attachTo(*this);
		context.setRenderer(this);
		context.setContinuousRepainting(true);
	}

	~OGLTestComponent() {
		context.detach();
	}
	
	virtual void paint(Graphics& g) {

	}

	virtual void newOpenGLContextCreated() {
		img = Image(Image::PixelFormat::ARGB, getBounds().getWidth(), getBounds().getHeight(), true);
	}

	virtual void renderOpenGL()
	{
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		// Create an OpenGLGraphicsContext that will draw into this GL window..
		ScopedPointer<LowLevelGraphicsContext> glRenderer(createOpenGLGraphicsContext(context, getWidth(), getHeight()));

		if (glRenderer != nullptr)
		{
			if (img.isValid())
			{
				Graphics g(*glRenderer);
				g.drawImage(img, getLocalBounds().toFloat());
			}
		}
	};

	virtual void openGLContextClosing() {
		img = Image::null;
	}

	Image img;
	OpenGLContext context;
};

#2

Do you have the same assert if you remove the image in the destructor instead of the OpenGL ContextClosing ? Do you even need to remove the image manually since it is deleted automatically with the class ?


#3

Your code looks fine to me. I’ve just copy&pasted your code and run it on a mac and I don’t get the assertion you are talking about. Which platform is this occurring on? Are you using the master or the develop branch?


#4

This is on windows in a VST3 Plugin, a child component of the editor. this assert fires when closing the editor.


#5

I’m seeing the same assertion on Windows AAX. I am currently on the develop branch, but last pulled 3/17/2017.