I’m porting one of our apps to Android - it already runs fine on iOS and desktop formats.
The app runs only in landscape and is hardcoded to 1024 x 768. I’m using setGlobalScaleFactor to account for different screen DPIs.
If I don’t use OpenGL, then the app scales perfectly to the screen but the graphics are sluggish.
If I attach an OpenGLContext to my MainComponent then the app appears squashed vertically but the touch sense acts as if the app has been rendered correctly, i.e. tapping slightly below where the button appears gets registered as a button press. The graphics are very responsive though
Is there something I need to do to get the OpenGL version to render correctly?
My best recommendation is using the SoundRadix branch, which has fixes for OpenGLContext scaling.
One thing we had to do as well: Don’t attach OpenGLContext to the top level component. Create a Component to hold your OpenGL Component, and attach the context to the OpenGL Component only. Between the SoundRadix fixes and that, we were able to fix our OpenGL issues.
Unfortunately, no. It appears that this problem has been happening for a while. The SR branch closely mirrors the main JUCE branch and doesn’t require additional changes to your codebase (i.e. no bonus virtual functions that need defined anywhere)
I’m trying to fix this but I am (once more) struggling to get the Android Studio debugger working. However, I think I’ve narrowed down the problem pretty far already.
Sorry this seems like a hard nut to crack. It’s actually a bug which occurs on all platforms except OS X. If fixed a bunch of other bugs along the way but it still not working properly. Jules will have a go at this today.
We’re still working on this issue. It requires some re-thinking of a few functions in ComponentPeer which will ultimately break backward compatibility with code directly using the ComponentPeer and global scaling factors. We need to think about how to do the changes without breaking too much.
Sorry this bug turned out to be much more involved than expected.
Thanks for the tip - I’ve now got the screen scaling correctly when using OpenGL.
One question, why is the ratio calculation in findDisplays d.dpi/150? Should it not be d.dpi/160? According to the Android docs, 1 density independent pixel corresponds to a physical pixel at 160 DPI. I’m targeting the Samsung Galaxy Tab A which has a DPI of 160, and it does not render correctly unless the ratio is 1:1.
With d.dpi/150 the GUI is rendered too large for the screen.