Re: How do I sync output changes to vertical retrace?
Barry Scott <[email protected]>
| Newsgroups | gmane.comp.xfree86.devel |
|---|---|
| Message-ID | <[email protected]> |
Mark Vojkovich wrote:
> The only mechanism I know of is OpenGL. Most OpenGL drivers have
> a mechanism to allow buffer swapping at vblank.
>
Using DRM/DRI this works:
void waitForVSync()
{
if( card_fd < 0 )
card_fd = open( "/dev/dri/card0", O_RDONLY );
drm_wait_vblank_t wait_vblank;
wait_vblank.request.type = _DRM_VBLANK_RELATIVE;
wait_vblank.request.sequence = 1;
wait_vblank.request.signal = 0;
int rc;
do
{
wait_vblank.request.type = _DRM_VBLANK_RELATIVE;
rc = ioctl( card_fd, DRM_IOCTL_WAIT_VBLANK, &wait_vblank );
}
while( rc != 0 && errno == EINTR );
}
Barry