diff --git a/internal/glfw/context_unix.c b/internal/glfw/context_unix.c index f56275404a29..1b75d02e0018 100644 --- a/internal/glfw/context_unix.c +++ b/internal/glfw/context_unix.c @@ -647,7 +647,7 @@ GLFWAPI void glfwSwapInterval(GLFWwindow* handle, int interval) _GLFW_REQUIRE_INIT(); - window->context.swapInterval(interval); + window->context.swapInterval(window, interval); } GLFWAPI int glfwExtensionSupported(GLFWwindow* handle, const char* extension) diff --git a/internal/glfw/context_windows.go b/internal/glfw/context_windows.go index 3ee361daf708..3e096cada1c2 100644 --- a/internal/glfw/context_windows.go +++ b/internal/glfw/context_windows.go @@ -513,7 +513,7 @@ func (w *Window) SwapInterval(interval int) error { return NotInitialized } - if err := w.context.swapInterval(interval); err != nil { + if err := w.context.swapInterval(w, interval); err != nil { return err } return nil diff --git a/internal/glfw/egl_context_unix.c b/internal/glfw/egl_context_unix.c index ba1fd98046bd..f21dc1a93562 100644 --- a/internal/glfw/egl_context_unix.c +++ b/internal/glfw/egl_context_unix.c @@ -244,7 +244,7 @@ static void swapBuffersEGL(_GLFWwindow* window) eglSwapBuffers(_glfw.egl.display, window->context.egl.surface); } -static void swapIntervalEGL(int interval) +static void swapIntervalEGL(_GLFWwindow* window, int interval) { eglSwapInterval(_glfw.egl.display, interval); } diff --git a/internal/glfw/glx_context_linbsd.c b/internal/glfw/glx_context_linbsd.c index 33afbae191de..bbb945be3049 100644 --- a/internal/glfw/glx_context_linbsd.c +++ b/internal/glfw/glx_context_linbsd.c @@ -165,11 +165,8 @@ static void swapBuffersGLX(_GLFWwindow* window) glXSwapBuffers(_glfw.x11.display, window->context.glx.window); } -static void swapIntervalGLX(int interval) +static void swapIntervalGLX(_GLFWwindow* window, int interval) { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); - assert(window != NULL); - if (_glfw.glx.EXT_swap_control) { _glfw.glx.SwapIntervalEXT(_glfw.x11.display, diff --git a/internal/glfw/internal_unix.h b/internal/glfw/internal_unix.h index a15de93415ce..807afefc23da 100644 --- a/internal/glfw/internal_unix.h +++ b/internal/glfw/internal_unix.h @@ -55,7 +55,7 @@ typedef struct _GLFWmutex _GLFWmutex; typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*); typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*); -typedef void (* _GLFWswapintervalfun)(int); +typedef void (* _GLFWswapintervalfun)(_GLFWwindow*, int); typedef int (* _GLFWextensionsupportedfun)(const char*); typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*); typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*); diff --git a/internal/glfw/internal_windows.go b/internal/glfw/internal_windows.go index aca499d14fd0..2411085e0d5d 100644 --- a/internal/glfw/internal_windows.go +++ b/internal/glfw/internal_windows.go @@ -87,7 +87,7 @@ type context struct { // TODO: Put these functions in an interface type. makeCurrent func(*Window) error swapBuffers func(*Window) error - swapInterval func(int) error + swapInterval func(*Window, int) error extensionSupported func(string) bool getProcAddress func(string) uintptr destroy func(*Window) error diff --git a/internal/glfw/nsgl_context_darwin.m b/internal/glfw/nsgl_context_darwin.m index 3d96557f5f46..9cdca7f5b580 100644 --- a/internal/glfw/nsgl_context_darwin.m +++ b/internal/glfw/nsgl_context_darwin.m @@ -52,13 +52,10 @@ static void swapBuffersNSGL(_GLFWwindow* window) } // autoreleasepool } -static void swapIntervalNSGL(int interval) +static void swapIntervalNSGL(_GLFWwindow* window, int interval) { @autoreleasepool { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); - assert(window != NULL); - [window->context.nsgl.object setValues:&interval forParameter:NSOpenGLContextParameterSwapInterval]; diff --git a/internal/glfw/osmesa_context_unix.c b/internal/glfw/osmesa_context_unix.c index 787c3075ba52..7a26203d8a13 100644 --- a/internal/glfw/osmesa_context_unix.c +++ b/internal/glfw/osmesa_context_unix.c @@ -71,7 +71,7 @@ static void swapBuffersOSMesa(_GLFWwindow* window) // No double buffering on OSMesa } -static void swapIntervalOSMesa(int interval) +static void swapIntervalOSMesa(_GLFWwindow* window, int interval) { // No swap interval on OSMesa } diff --git a/internal/glfw/wgl_context_windows.go b/internal/glfw/wgl_context_windows.go index 305755f97dac..a0233b18cd64 100644 --- a/internal/glfw/wgl_context_windows.go +++ b/internal/glfw/wgl_context_windows.go @@ -288,13 +288,7 @@ func swapBuffersWGL(window *Window) error { return nil } -func swapIntervalWGL(interval int) error { - ptr, err := _glfw.contextSlot.get() - if err != nil { - return err - } - window := (*Window)(unsafe.Pointer(ptr)) - +func swapIntervalWGL(window *Window, interval int) error { window.context.platform.interval = interval if window.monitor == nil && winver.IsWindowsVistaOrGreater() {