Opengl render in android


#1

when i use juce develop android app
I get poor graphics performance,
i check the source code found that android is use java canvas to draw gui
so when i drag some items or paint large image the gui is lag…
can somebody add a opengl render to android?


#2

Take a look at the Juce Demo app - Build it on your Android device.

How does it run? *Especially* the OpenGL demo!

A

I created a simple app (essentially ripping out all of the rest of the demo, except for the OpenGl demos) in under an hour - I got it to load my own object data, and it renders very quickly (takes a few seconds to load the large object)

 


#3

I know how to draw opengl content, but i means using opengl to render GUI components, such as listbox, textbox..... 


#4

See OpenGLContext::attachTo

If you search in the demo app, it has an example of how to use this.


#5

There is an issue in the current JuceAppActivity java template when using an OpenGL context that leads to terrible touch event performance.  In the ComponentPeerView inner class, the onDraw() gets called by the runtime on every touch down event, and handlePaint (a native method) is called.  But the problem is that when it has added a GL context, the handlePaint() attempts to render in the *software rendering* pipeline causing massive slowdowns.  I added an additional boolean state to ComponentPeerView to keep track of when an OpenGL context was added (in its createGLView() method), and if so, *do not* call handlePaint, because it is unnecessary for the GL renderer.

 

I don't know why the java runtime is calling the onDraw method on touch down events in the first place, but it seems like a bad idea regardless.  Preventing onPaint from being called was critical when GL is the context, though.

 

This made such a huge difference in interactivity, that I could actually commit to using JUCE for my app!


#6

I've got my app rendering with OpenGL now - and I can see performance gains in non-interactive animations / screen updates.

However still seeing slightly jerky / stepped animation e.g. when dragging a component on the screen. I've tried Sonosaurus's suggestion but not seeing much difference. I'm trying to figure out how best to check whether handlePaint() should be called. 

 


#7

So, I tested the time between touch events (via Java log) on mouseDrag (ACTION_MOVE) and its averaging around 70-85ms. I'm not sure why its so slow. I'm digging around to see if there's anything that can be done on the Java side. 

UPDATE: Testing on an HTC Desire, with OpenGL switched on (via attachTo on topLevelComponent) I get crazy graphical glitches appearing. Same APK runs fine on a Samsung Galaxy Ace 2. I've switched back to software rendering for now, as I think my performance issues stem from elsewhere. 


#8

Hi adamski!

Any news on how you worked this out?

For me Opengl::attachto increases drawing performance by a lot on my nexus but makes it unusable on my htc One with crazy glitches.

And my drawing performance is great (on my Nexus) using opengl attachto except when doing some touch input, then it lags.


#9

No - I added a test to check for HTC devices (well HTC Desire at least as thats what I have) and use software rendering in that case.


I've been more focused on iOS in the last 6 months so not been doing much Android testing... I would have hoped this issue would have been fixed by now..?