2

I am using JPCT-AE on a GLSurfaceView to create a live wallpaper. First I left the renderer do draw on the surface freely (not trying to cap the frame rate in any way). Obviously, the cpu usage went to 90% (using a Defy+ with gingerbread -- my wallpaper rendered a single rotating sphere containing ~200 polys without lighting).

Now I have set the renderMode to "RENDERMODE_WHEN_DIRTY" on the surface and request the render to draw frames each 33ms using a Runnable posted by a Handler:

glSurfaceView.setRenderer(renderer);
glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

final Handler handler = new Handler();
handler.postDelayed(new Runnable(){
    public void run() {
        glSurfaceView.requestRender();      
        handler.postDelayed(this, 30);
    }
}, 40);

It reduced the cpu usage to something between 1% - 10%, which is great, but now I'm wondering whether this is the best way to do this or not.

Is there a better way to improve the rendering performance of a GLSurfaceView? Is this method I am using technically correct or it's going to give me some headaches later?

Thank you.

arvere
  • 727
  • 1
  • 7
  • 21

0 Answers0