diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 5e6fad42..8546e873 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -941,6 +941,8 @@ extern "C" { */ #define GLFW_POSITION_Y 0x0002000F +#define GLFW_SWAP_INTERVAL 0x00020010 + /*! @brief Framebuffer bit depth hint. * * Framebuffer bit depth [hint](@ref GLFW_RED_BITS). diff --git a/src/context.c b/src/context.c index cc1fac4f..d1160c92 100644 --- a/src/context.c +++ b/src/context.c @@ -364,6 +364,9 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, if (_glfwPlatformGetTls(&_glfw.contextSlot) != window) return GLFW_FALSE; + if (window->swapInterval != -1) + window->context.swapInterval(window->swapInterval); + window->context.GetIntegerv = (PFNGLGETINTEGERVPROC) window->context.getProcAddress("glGetIntegerv"); window->context.GetString = (PFNGLGETSTRINGPROC) diff --git a/src/internal.h b/src/internal.h index 1ab3dea8..3991c61f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -402,6 +402,7 @@ struct _GLFWwndconfig GLFWbool focusOnShow; GLFWbool mousePassthrough; GLFWbool scaleToMonitor; + int swapInterval; struct { GLFWbool retina; char frameName[256]; @@ -526,6 +527,7 @@ struct _GLFWwindow GLFWbool focusOnShow; GLFWbool mousePassthrough; GLFWbool shouldClose; + int swapInterval; void* userPointer; GLFWbool doublebuffer; GLFWvidmode videoMode; diff --git a/src/window.c b/src/window.c index 51903e63..b4826808 100644 --- a/src/window.c +++ b/src/window.c @@ -233,6 +233,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->focusOnShow = wndconfig.focusOnShow; window->mousePassthrough = wndconfig.mousePassthrough; window->cursorMode = GLFW_CURSOR_NORMAL; + window->swapInterval = wndconfig.swapInterval; window->doublebuffer = fbconfig.doublebuffer; @@ -274,6 +275,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.window.focusOnShow = GLFW_TRUE; _glfw.hints.window.xpos = GLFW_ANY_POSITION; _glfw.hints.window.ypos = GLFW_ANY_POSITION; + _glfw.hints.window.swapInterval = -1; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered @@ -395,6 +397,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_MOUSE_PASSTHROUGH: _glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_SWAP_INTERVAL: + _glfw.hints.window.swapInterval = value; + return; case GLFW_CLIENT_API: _glfw.hints.context.client = value; return;