3
\$\begingroup\$

I have an application with a very light rendering loop, taking a predictable and small time to execute. Right now, I have two solutions. The first solution uses Vsync: after a screen update, my application renders one frame immediately and then waits for the next screen update. This adds approximately one frame of latency. The second solution simply renders continuously, consuming the whole CPU and relying on OpenGL-style triple buffering to catch the correct frame.

Is there a way for me to acquire the monitor screen update timepoints, preferably through some kind of callback? My current workflow is GLFW with OpenGL, but other solutions are welcome too. I wish to produce a hybrid solution: after a screen update, it should wait for nearly an entire frame, render one frame, and then the screen update will catch this just-rendered frame. GLFW's glfwSwapInterval is almost what I want, but it works in the opposite way, by swapping the buffer right after the screen update instead of before.

With the screen update timepoints, I will be able to implement what I want, by measuring confidence intervals around my rendering loop's execution time and waiting for the correct duration.

\$\endgroup\$
2
  • \$\begingroup\$ What OS are you on? There are different solutions for different operating systems. \$\endgroup\$ Dec 8, 2017 at 3:27
  • \$\begingroup\$ I'm on both Windows and Linux, and will be happy with solutions for either OS. (I'm also on HTML thanks to emscripten but have little hope for a solution there.) \$\endgroup\$ Dec 8, 2017 at 4:17

0

You must log in to answer this question.

Browse other questions tagged .