c++winapiopenglframe-rate

How to request higher refresh rate for animation under Windows dynamic refresh rate?


I'm developing my own toy UI framework in C++ using OpenGL. However, animations seem to be capped at 60Hz when dynamic refresh rate (DRR) is on, whereas I have a display with 120Hz. It seems like the framerate jumps up intermittently, e.g. when I'm moving the cursor. I'm wondering if there's some way I can request a higher refresh rate when an animation is about to happen? I know DRR is a major issue for Chrome and Firefox as well, and it's supposed to have to be enabled by the application. But what does that look like? Is there an API for this?

I've tried searching through Microsoft's documentation, but I wasn't able to find any info on this. Is there something I'm missing? How does Windows's DRR implementation work? Is it opt-in or is the OS supposed to handle this for you?


Solution

  • I have no experience with this API but it seems that Windows offers a "compositor clock API" that might be helpful - it is most likely that OpenGL support can require some low-level hacking though...

    https://learn.microsoft.com/en-us/windows/win32/directcomp/compositor-clock/compositor-clock