我想知道是否可以通过任何文件描述符捕获屏幕 vsync 事件并 [select | 民意调查 | epoll]。
通常,如果我是对的, glXSwapBuffers() 不会阻止该过程,因此我可以执行以下操作:
int init() {
create epollfd;
add Xconnection number to it;
add some other fd like socket timer tty etc...
possibly add a vsync fd like dri/card0 or fb0 or other???
return epollfd;
}
main() {
int run = 1;
int epollfd = init();
while(run) {
epoll_wait(epollfd, ...) {
if(trigedfd = socket) {
do network computing;
}
if(trigedfd = timer) {
do physics computing;
}
if(trigedfd = tty) {
do electronic communications;
}
if(trigedfd = Xconnection number) {
switch(Xevent) {
case key event:
do key computing;
case mouse event:
do mouse computing;
case vsync???:
do GL computings;
glXSwapBuffers();
}
}
if(trigedfd = dri/card0 or fb0 or other???) {
do GL computings;
glXSwapBuffers();
}
}
}
因此,无论何时发生 vsync 事件,我都可以触发任何事件,并在仅使用 X 绘图功能和可能 GL 进行 vsync 的情况下避免撕裂效应。
libdrm 可以帮助我吗?更普遍的问题是:
那么我必须使用什么 fd 来捕获 vsync 事件以及如何使这个 fd 上发生的事件是 vsync 事件?