glfwSwapInterval function

void glfwSwapInterval(
  1. int interval
)

! @brief Sets the swap interval for the current context.

This function sets the swap interval for the current OpenGL or OpenGL ES context, i.e. the number of screen updates to wait from the time @ref glfwSwapBuffers was called before swapping the buffers and returning. This is sometimes called vertical synchronization, vertical retrace synchronization or just vsync.

A context that supports either of the WGL_EXT_swap_control_tear and GLX_EXT_swap_control_tear extensions also accepts negative swap intervals, which allows the driver to swap immediately even if a frame arrives a little bit late. You can check for these extensions with @ref glfwExtensionSupported.

A context must be current on the calling thread. Calling this function without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.

This function does not apply to Vulkan. If you are rendering with Vulkan, see the present mode of your swapchain instead.

@paramin interval The minimum number of screen updates to wait for until the buffers are swapped by @ref glfwSwapBuffers.

@errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.

@remark This function is not called during context creation, leaving the swap interval set to whatever is the default on that platform. This is done because some swap interval extensions used by GLFW do not allow the swap interval to be reset to zero once it has been set to a non-zero value.

@remark Some GPU drivers do not honor the requested swap interval, either because of a user setting that overrides the application's request or due to bugs in the driver.

@thread_safety This function may be called from any thread.

@sa @ref buffer_swap @sa @ref glfwSwapBuffers

@since Added in version 1.0.

@ingroup context

GLFWAPI void glfwSwapInterval(int interval)

Implementation

void glfwSwapInterval(int interval) {
  final glfwSwapIntervalLookupFunction = libglfw.lookupFunction<
      Void Function(Int32 interval),
      void Function(int interval)>('glfwSwapInterval');
  return glfwSwapIntervalLookupFunction(interval);
}