I'm trying to use the OpenGLImageType class but it won't display when I try to draw just a subsection of the image.
Here's a small MainComponent that reproduces the problem.
class MainContentComponent : public Component, public OpenGLRenderer { public: MainContentComponent(); void paint (Graphics&) override; void newOpenGLContextCreated() override; void renderOpenGL() override; void openGLContextClosing() override; private: JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent) OpenGLContext _context; Image _image; };
.cpp
MainContentComponent::MainContentComponent() { setSize (600, 400); _context.setRenderer(this); _context.attachTo(*this); } void MainContentComponent::paint (Graphics& g) { g.fillAll(Colours::black); jassert(_context.isActive()); g.drawImage(_image, 0, 0, getWidth(), getHeight(), 0, 0, _image.getWidth() / 2, _image.getHeight() / 2); } void MainContentComponent::newOpenGLContextCreated() { auto cpuImage = ImageCache::getFromMemory(BinaryData::canvas1_png, BinaryData::canvas1_pngSize); _image = OpenGLImageType().convert(cpuImage); } void MainContentComponent::renderOpenGL() { } void MainContentComponent::openGLContextClosing() { }
This code works as expected when using an image created directly from ImageCache::getFromMemory(...) but the image doesn't display when using OpenGLImageType. This has been tested using the latest juce on OSX