如何在Xlib应用程序中等待VSYNC? [英] How to wait for VSYNC in Xlib app?

查看:101
本文介绍了如何在Xlib应用程序中等待VSYNC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XWindow Drawable,Pixmap和XRender在屏幕上绘制一些东西.我可以看到有时会出现闪烁.有没有办法等待VBLANK?我已经在Google上搜索了很多,感觉就像在森林里寻找一枚硬币.

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.

不涉及OpenGL.它是Linux(Ubuntu). 我可以使用(nano)sleep(),但是需要知道什么时候该画画了.

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.

推荐答案

我发现迄今为止最简单的解决方案是使用GLX,因为它具有出色的同步和双缓冲高级界面.请注意,GLX不是OpenGL,它是X扩展名.您需要一个虚拟的OpenGL上下文,因为SwapBuffers(出于某种奇怪的原因)需要它,但仅此而已.

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.

如果出于任何原因要在没有GLX的情况下执行此操作,则可以通过X Double Buffer Extension(DBE)创建双缓冲区并使用X Syncronization Extension手动同步以使其显示.我自己还没有这样做,但是您应该可以按自己的喜好调用XSyncListSystemCounters(在正确的初始化之后!)找到一些东西:

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返回一个指向显示器支持的系统计数器数组的指针

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.

这篇关于如何在Xlib应用程序中等待VSYNC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆