mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 00:30:57 +00:00
NSGL: Update current display for display link
This solution of one display link per window is far from ideal but is still better than no solution. As a side-effect this fixes swap interval breaking being ignored for occluded windows on earlier versions of macOS. Fixes #680. Fixes #1337. Related to #1417. Fixes #1435.
This commit is contained in:
+13
-5
@@ -367,6 +367,8 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
|
||||
[window->context.nsgl.object setView:window->ns.view];
|
||||
|
||||
window->context.nsgl.swapIntervalCond = [NSCondition new];
|
||||
|
||||
window->context.makeCurrent = makeContextCurrentNSGL;
|
||||
window->context.swapBuffers = swapBuffersNSGL;
|
||||
window->context.swapInterval = swapIntervalNSGL;
|
||||
@@ -378,16 +380,22 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
CVDisplayLinkSetOutputCallback(window->context.nsgl.displayLink,
|
||||
&displayLinkCallback,
|
||||
window);
|
||||
CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(window->context.nsgl.displayLink,
|
||||
(CGLContextObj) window->context.nsgl.object,
|
||||
(CGLPixelFormatObj) window->context.nsgl.pixelFormat);
|
||||
CVDisplayLinkStart(window->context.nsgl.displayLink);
|
||||
|
||||
window->context.nsgl.swapIntervalCond = [NSCondition new];
|
||||
|
||||
_glfwUpdateDisplayLinkDisplayNSGL(window);
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwUpdateDisplayLinkDisplayNSGL(_GLFWwindow* window)
|
||||
{
|
||||
CGDirectDisplayID displayID =
|
||||
[[[window->ns.object screen] deviceDescription][@"NSScreenNumber"] unsignedIntValue];
|
||||
if (!displayID)
|
||||
return;
|
||||
|
||||
CVDisplayLinkSetCurrentCGDisplay(window->context.nsgl.displayLink, displayID);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW native API //////
|
||||
|
||||
Reference in New Issue
Block a user