timer driven or endless loop update?

对着背影说爱祢 提交于 2019-12-12 05:57:21

问题


I've been perplexed for a while, whether to run the rendering loop in an endless loop or whether to drive it with a timer (say, a 60 Hz timer). The endless loop seems a good idea, but I am worried it might leech a battery on portable devices faster than the timer approach. In general, consume more energy. I've seen both approaches used in practice, but can't decide on the positive and negative points of them. Can you please help me decide? Perhaps most portable devices are too primitive to support VSync updates and hence timer use on them is necessary?


回答1:


Android has capability to do both (Refer http://developer.android.com/reference/android/opengl/GLSurfaceView.html), RENDERMODE_CONTINUOUSLY or RENDERMODE_WHEN_DIRTY flags. Qt and other frameworks also have this. So embedded frameworks do have this capability. However fast you render, note that modern display frameworks (when using their API) will always switch the next frame only at vsync timing, so if you need to draw faster than vsync for some reason, you need to be able to bypass the API (ex, draw direct to the framebuffer).

If the fastest update rate is needed independent of any display synchronisation, go for continuous updates, and this will take more power (not maximum power - you can decide to update selective portions of the screen).



来源:https://stackoverflow.com/questions/20879498/timer-driven-or-endless-loop-update

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