mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 13:46:37 +00:00
Implemented single GLRC option on MacOS port.
This commit is contained in:
parent
4207a0a09b
commit
a179278e2f
@ -30,7 +30,12 @@
|
|||||||
static void makeContextCurrentNSGL(_GLFWwindow* window)
|
static void makeContextCurrentNSGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window)
|
if (window)
|
||||||
|
{
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
[window->context.nsgl.object setView:window->ns.view];
|
||||||
|
#endif
|
||||||
[window->context.nsgl.object makeCurrentContext];
|
[window->context.nsgl.object makeCurrentContext];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
[NSOpenGLContext clearCurrentContext];
|
[NSOpenGLContext clearCurrentContext];
|
||||||
|
|
||||||
@ -79,7 +84,12 @@ static void destroyContextNSGL(_GLFWwindow* window)
|
|||||||
[window->context.nsgl.pixelFormat release];
|
[window->context.nsgl.pixelFormat release];
|
||||||
window->context.nsgl.pixelFormat = nil;
|
window->context.nsgl.pixelFormat = nil;
|
||||||
|
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if (window->context.customctx)
|
||||||
|
[window->context.nsgl.object release];
|
||||||
|
#else
|
||||||
[window->context.nsgl.object release];
|
[window->context.nsgl.object release];
|
||||||
|
#endif
|
||||||
window->context.nsgl.object = nil;
|
window->context.nsgl.object = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +291,22 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if (ctxconfig->share)
|
||||||
|
{
|
||||||
|
// Use shared context instead of creating a new one
|
||||||
|
window->context.nsgl.object = ctxconfig->share->context.nsgl.object;
|
||||||
|
window->context.customctx = GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create new GL context
|
||||||
|
window->context.nsgl.object =
|
||||||
|
[[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
|
||||||
|
shareContext:nil];
|
||||||
|
window->context.customctx = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
#else
|
||||||
NSOpenGLContext* share = NULL;
|
NSOpenGLContext* share = NULL;
|
||||||
|
|
||||||
if (ctxconfig->share)
|
if (ctxconfig->share)
|
||||||
@ -289,6 +315,8 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||||||
window->context.nsgl.object =
|
window->context.nsgl.object =
|
||||||
[[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
|
[[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
|
||||||
shareContext:share];
|
shareContext:share];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (window->context.nsgl.object == nil)
|
if (window->context.nsgl.object == nil)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
||||||
|
Loading…
Reference in New Issue
Block a user