Newbie Questions: Trying to understand glfwSwapInterval

The documentation on glfwSwapInterval and buffer swapping should hopefully answers most of your questions.

Some brief answers to your specific questions, but please read the above in detail and also search and read about vertical synchronization or vsync.

Question #1 What are the best practices I should take?
The normal best practice is to let your end user choose, and default to 1.

Question #2 What are the differences between setting the interval to 1, 0, or just not calling the function?

  • Not calling: driver default
  • 0: do not wait for vsync (may be overridden by driver/driver settings)
  • 1: wait for 1st vsync (may be overridden by driver/driver settings)

Question #3 What happens during glfwSwapBuffers when interval is set to 1?
If you set the swap interval to 1, and the driver does not override this, then calling glfwSwapBuffers will call the opengl swap buffer implementation which will then wait until the buffer has swapped. You won’t be able to do anything with this thread until then, but you can use multithreading to do other work.

3 Likes