0

I'm starting to learn the GPipe library, and was wondering how someone could accomplish vsync and FPS control with it. Initially, I was thinking a separate thread could block every 1 * 1000000 / FPS microseconds and run swapContextBuffers, but that would mean the separate thread would need to build its own ContextT, and thus it's own window.

The docs on the function itself mentions briefly that it could block if VSync is enabled in the system - what does this mean? How would I enable it?

Athan Clark
  • 3,886
  • 2
  • 21
  • 39
  • Most graphics drivers have configurations to either always enable vsync, completely disable vsync, or enable vsync if the application requests it. That's likely what "in the system" means. – Colonel Thirty Two Jan 06 '16 at 04:47
  • That's really not how you want to implement some sort of VSYNC system of your own. D3D's a lot more sophisticated here, and you can use event-based timing to wait for the VBLANK signal from the driver even if VSYNC is disabled. Various vendor extensions to do this in GL may exist, though I've never even bothered. Unless you're doing something rather exotic that needs low input latency + VSYNC, simply using a non-zero swap interval is usually adequate. – Andon M. Coleman Jan 06 '16 at 19:15
  • Thank you both, that answers one question. But what about a manually controlled FPS rate? Could I asynchronously swap the context buffers? What would be a good method to controlling this? – Athan Clark Jan 07 '16 at 20:36
  • You might find the documentation for [glfwSwapInterval](http://www.glfw.org/docs/latest/group__context.html) useful. – Brett Hale Jan 08 '16 at 07:12

1 Answers1

1

Setting the swap interval is specific for the window manager in OpenGl. In the case of GLFW, you need to call glfwSwapInterval. Unfortunately, you cannot do it yourself in GPipe since the thread your ContextT is running on doesn't have the GL context current. This should really be implemented in GPipe-GLFW's context creation instead, i.e. inside newContext'.

And no, you cannot asynchronously swap the buffers in GPipe (but you wouldn't want to do that even if it was possible).