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\$
  • \$\begingroup\$ What OS are you on? There are different solutions for different operating systems. \$\endgroup\$ – user1118321 Dec 8 '17 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\$ – low latency Dec 8 '17 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.