I've got a native library for a game I'm porting from iPhone to Android. Our target OS version is 1.6, and the game overall works pretty well with no optimizations. However, the moment I enable optimizations of any kind (be it -O1, -O2 or -O3), everything (Input, Graphics, Sound, game code) but the graphics work properly.
Here's what I'm supposed to get:
http://i56.tinypic.com/2yzn4o6.png
And what I get:
http://i51.tinypic.com/raqogl.png
I've already tried to get some help on the NDK mailing lists but I got no replies. I even tried to send the textures as pure white and they behave even more strangely, with tiny white triangles "falling" while in the Loading Screen until the whole screen turns white, while I'm only drawing a couple of triangles.
I'm using vs-android to compile, but even with NDK-build I have the same problem. I also verified that the pixel data I'm getting from the textures is 100% valid (I dumped it to PNGs on the SD-card while debugging).
Any help is appreciated.
Apparently some compilers might optimize your files incorrectly and cause these sorts of graphical bugs. If you have some kind of bug that doesn't happen on other platforms, such as in my case, this OpenGL bug, you can possibly solve it on Android if you first disable optimizations on all your files and then re-enable them sequentially until you find the source file responsible for your bug. In my case it was an OpenGL texturing file that was somehow being incorrectly compiled.