OpenGL renderer + images

I've been trying to port an existing Juce based iOS app to Android using Juce's Android bindings, and I've been having trouble with the app being sluggish.  I enabled the OpenGl renderer, but it hasn't really helped.  I am using a lot of image files though, and I haven't been sure about the optimal way to handle images when the OpenGL renderer is enabled.  Ideally, the images should be turned into OpenGL textures, and I don't know if Juce is already doing that for the app or not.  

I have one method where all the images are being retrieved from by name.  In this method I could create OpenGL textures for the images and copy the image data over to the textures.  But I also remember reading somewhere that you can't do this unless the OpenGL context is active.  I'm sure there must be an explanation somewhere of what the optimal way to handle image data is when the OpenGL renderer is enabled.  Could someone point me to it?

Actually, this thread seems to have a lot of answers:

http://www.juce.com/forum/topic/using-opengl-2d-components

 

You have to create your textures as OpenGLImageType otherwise Juce winds up copying them over to GL all the time, which does not give you a speedup.

There's a problem though with OpenGLImageType on Android. basically Android likes to throw your GLContent any time it likes (for example changing orientation or launch sub-activity). You have to catch these and re-load your textures of this type back into the context, otherwise it will go black.

 

 

1 Like

Thanks for the tip.  How do you check whether Android has chucked out the image?  

Test whether OpenGLImageType::getFrameBufferFrom (const Image &) returns a non null OpenGLFrameBuffer and whether that frame buffer's isValid() method returns true?

you get OpenGLRenderer::newOpenGLContextCreated() called. this can happen even though, `openGLContextClosing" is not called (but only for Android).

What i do is keep a list of textures i've made and passed to OGL, then i put them all back each time this happens.