How to copy an Image with OpenGLImageType()?

Hi guys,

I’m probably forgetting something obvious, but when I try to copy an Image with OpenGLImageType() I’m hitting an assert. Of course I’m calling both functions from within a render loop, so there should be an active context. The problem happens whether I call it from OpenGLRenderer::newOpenGLContextCreated () or from OpenGLRenderer::renderOpenGL ()

outputImage = Image(Image::PixelFormat::ARGB, currentComponent->getWidth(), currentComponent->getHeight(), true, OpenGLImageType());
Image test = outputImage.createCopy() //try to copy the Image

The assert I’m hitting. JUCE Assertion failure in juce_OpenGLGraphicsContext.cpp:221:

jassert (frameBufferID != 0); // trying to render into an uninitialised framebuffer object.

So how do I successfully create a (deep) copy of an OpenGLImageType?

Looks like the initialise method for the underlying image data is not actually called if you are creating a copy:

This sounds like a bug because using OpenGLImageType::create() will correctly initialise the underlying framebuffer:

Hmm, interesting. If I use the following sequence, things do work:

outputImage = Image(Image::PixelFormat::ARGB, currentComponent->getWidth(), currentComponent->getHeight(), true, OpenGLImageType());
Image test = Image(Image::PixelFormat::ARGB, currentComponent->getWidth(), currentComponent->getHeight(), false, OpenGLImageType());
Graphics g = Graphics(test);
g.drawImage(outputImage, outputImage.getBounds().toFloat(), RectanglePlacement(), false);

Which seems to be very close to the sequence that is used internally in createCopy(), so this might indeed be a bug in JUCE itself, can anyone confirm?

I too believe there’s a missing call to initialise() there.