Alternative CVDisplayLink for Windows?

On Mac OS X, CVDisplayLink provides a great way to reliably refresh your screen to reach 60 frames per second without a break. Is there a similar interface on Windows compatible with OpenGL?

Of course, you can lock while waiting for vsync, but it does not scale for multiple windows that need to be animated at the same time. On Windows, everyone will be waiting for each other (so two windows, each of which is waiting for vsync, will drop to 30 frames per second), unlike OS X.

How, for example, does a video player perform a smooth screen update?

+6
source share
1 answer

The typical architecture for Windows is different from the Mac, because you control the main loop and not the OS libraries - there is no need for the CVDisplayLink equivalent (although, of course, if the APIs were better, you would not need to know how to get this information very specific information).

If you use a loop that rotates endlessly, then waiting for vsync at the end of the loop is fine. If you have multiple windows, you need to schedule the rendering accordingly, so that your "main update cycle" ends with waiting for vsync after the rendering is submitted.

Usually I have something like this:

while(!toldToQuit) { Render(); Update(); WaitForVsync(); } 

which allows the processor to work for updating (for the next frame) so that it works with the GPU for rendering ...

SwapBuffers (HDC) will wait for vsync if the driver has this by default, otherwise there is a wgl extension for installing vsync-wglSwapIntervalEXT (int):

http://www.opengl.org/registry/specs/EXT/wgl_swap_control.txt

the way that I always achieved β€œnot vsyncing” is to render single buffered and non-invoking SwapBuffers ... since wglSwapIntervalEXT (0) does not achieve this on any hardware that I tested it on.

+1
source

Source: https://habr.com/ru/post/915680/


All Articles