Frametime / Framerate measurement for Android GLSurfaceView.Renderer

I have an application that uses OpenGL ES 2.0, and uses the GLSurfaceView class and the Renderer class to draw on the screen. I initially set rendermode to RENDER_WHEN_DIRTY, and then called requestRender()60 times per second, determining how long it took to complete the function, but I consistently got incredibly short time frames (high frame rates) when the program was VERY behind my phone. I then suggested that this is because it requestRender()only sends a visualization request, rather than actually invoking onDrawFrame(), and so time would be pointless.

Then I decided to synchronize in a valid function onDrawFrame(). I used the functions SystemClock.elapsedRealtime()at the beginning and at the end, and calculated the difference, and again, I got frames of more than 70, when in fact my phone showed more than 1000 vertices and lagged far behind.

So, how should you calculate the cycle time / frame rate, and at what points should you start / stop time?

+4
source share
1 answer

requestRender() . , , . , , -, .

onDrawFrame() , , . OpenGL , CPU. , API OpenGL, . , , GPU , , GPU.

, onDrawFrame(), , , OpenGL, , , , . GPU .

, , , - (, ) . , , , .

, , . , onDrawFrame() onDrawFrame(). , , , . , onDrawFrame() . , Android , " ". , 1-2 , .

OpenGL , " ", , GPU . ​​ ES 3.1.

+4

All Articles