News for hackers. Stuff that matters.
Re:Minimal Cross-Platform Graphics by abainbridge on Tuesday January 24, 2023 @04:43AM (#34501612)
I used to use a timer to limit the frame rate to 60 Hz too. But on Windows, I found that DwmFlush() seems to act like WaitVSync(), so I've been using that in preference for years now. I think this is undocumented behaviour. I guess what it actually does is wait until the compositor is ready for another frame.

To be able to call that function, I LoadLibrary("dwmapi.dll"), and then GetProcAddress(dwm, "DwmFlush").

Re:Minimal Cross-Platform Graphics by suby on Tuesday January 24, 2023 @05:44AM (#34501998)
Why not just use VSync?
Re:Minimal Cross-Platform Graphics by sylware on Tuesday January 24, 2023 @06:08AM (#34502156)
If I am not too much mistaken, because on some hardware (mobile), there is no vsync feedback.

vsync feedback support has to be queried (look at vulkan API/wayland API). Usually it is called "presentation" something.

Re:Minimal Cross-Platform Graphics by abainbridge on Tuesday January 24, 2023 @08:34AM (#34503329)
How would I do that? I think there is any such function in the Win32 API.
Re:Minimal Cross-Platform Graphics by pavlov on Tuesday January 24, 2023 @12:16PM (#34506641)
Yes, I think you basically have to use a DirectX swap chain to get vsync presentation.
Re:Minimal Cross-Platform Graphics by dblohm7 on Wednesday January 25, 2023 @01:49PM (#34522464)
Re:Minimal Cross-Platform Graphics by formerly_proven on Tuesday January 24, 2023 @08:21AM (#34503195)
> Issues a flush call that blocks the caller until the next present, when all of the Microsoft DirectX surface updates that are currently outstanding have been made.

DWM always runs with vsync so presents never happen more frequently than screen refreshes.