问题
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