Android EGL/OpenGL ES Frame Rate Stuttering

杀马特。学长 韩版系。学妹 提交于 2019-12-02 23:08:20

Not sure if this is the answer, but note that the call to eglSwapBuffers() blocks for at least 16 ms, even if there is nothing to draw.

Running the game logic in a separate thread could win back some time.

Check out the blog post at the open source Platforming game Relica Island. The game logic is heavy, yet the framrate is smooth due to the authors pipeline/double buffer solution.

http://replicaisland.blogspot.com/2009/10/rendering-with-two-threads.html

You are not binding the framerate yourself. So it's bound by CPU.

Which means that it will run fast when the CPU has nothing to do and slower when it's doing other stuff.

Other stuff is running on your phone, which occasionally takes CPU time from your game. Garbage Collector will also to this, although not freezing your game like it used to do (since it now runs in a separate thread)

You would see this happen on any multiprogramming operating system that was in normal use. It's not just Java's fault.

My suggestion: bind the framerate to a lower value if constant bitrate is required. Hint: use a mix of Thread.sleep() and busy waiting (while loop), since sleep might go over the required waiting time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!