I'm finding that Android's behaviour with regards to setting the screen
size is really, really bizarre. Apparently Java, ANativeWindow and EGL
have different ideas as to how big the screen is. Ideally the three
sizes should always be the same, but this turns out not to be the case.
On application startup, after I get AGP_CMD_INIT_WINDOW, Java gets the
size right, but EGL and ANativeWindow think the screen is 1x1. The EGL
and ANativeWindow size only get updated after I create an EGL surface,
context, bind them, and then draw on the screen with eglSwapBuffers().
when the application's screen changes size, I get sent a
AGP_CMD_CONFIG_CHANGED. Java's size has changed. But ANativeWindow's
size only changes a couple of events later, and EGL's size, again, only
changes after I've drawn on the screen.
if I put the application to the background (I get an
AGP_CMD_TERM_WINDOW), change the orientation, and bring it to the
foreground (AGP_CMD_INIT_WINDOW), Java's size has updated. But
ANativeWindow and EGL's size don't update until later... if they update
at all, which sometimes they don't!
I find the behaviour changes drastically depending on what device I'm
on. The worst culprit is a Samsung Galaxy Y running 2.3.6. I'm quite
willing to believe that given Samsung's history, at least some of this
is due to the vendor subtly breaking stuff --- but it doesn't really
matter; I have to make this work anyway.
My attempts to work around the above issues are resulting in an
ever-more complex and brittle state machine and it's becoming completely
unworkable. Normally I'd just copy someone else code, but unfortunately
the NDK doesn't come with any NativeActivity OpenGL samples!
Can anyone point me at a known correct implementation of handing screen
resizing, backgrounding etc using NativeActivity and OpenGL that I can
use for reference?
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "Parents let children ride bicycles on the street. But parents do not
│ allow children to hear vulgar words. Therefore we can deduce that
│ cursing is more dangerous than being hit by a car." --- Scott Adams
Does anyone know *anything* about this? This issue is blocking our
entire product, and I need assistance...