How to wait for VSYNC in Xlib app?

纵然是瞬间 提交于 2019-11-27 14:09:31

问题


I am drawing something on screen using XWindow Drawable, Pixmap, and XRender. I can see that sometimes there is flicker. Is there a way to wait for VBLANK? I googled a lot already, feels like looking for a coin in a forest.

There is NO OpenGL involved. It is Linux (Ubuntu). I could use (nano)sleep(), but need to know when the time to draw has come some how.


回答1:


I find the by far most simple solution is using GLX because of its excellent high level interface towards synchronization and double buffering. Please note GLX is not OpenGL, it is an X extension. You need a dummy OpenGL context as SwapBuffers (for some odd reason) demands it but that´s about it.

If you want to do it without GLX for any reason, you can do it by creating double buffers through X Double Buffer Extension (DBE) and syncronize manually towards display using the X Syncronization Extension. I have not done so myself but you should be able to find something to your liking calling XSyncListSystemCounters (after proper initialization!):

XSyncListSystemCounters returns a pointer to an array of system counters supported by the display

Can´t find much more myself about the hard way though. Good Luck.



来源:https://stackoverflow.com/questions/30277659/how-to-wait-for-vsync-in-xlib-app

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