mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 21:56:36 +00:00
Merge 76324979b9
into 8055dad7e4
This commit is contained in:
commit
6dbe1736e7
@ -23,6 +23,7 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
|
|||||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
|
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
|
||||||
option(GLFW_INSTALL "Generate installation target" ON)
|
option(GLFW_INSTALL "Generate installation target" ON)
|
||||||
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
|
option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF)
|
||||||
|
option(GLFW_OPENGL_SINGLE_GLRC "Build the GLFW to use only a single OpenGL render context" OFF)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
@ -67,6 +68,10 @@ if (GLFW_BUILD_DOCS)
|
|||||||
find_package(Doxygen)
|
find_package(Doxygen)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (GLFW_OPENGL_SINGLE_GLRC)
|
||||||
|
add_definitions(-D_GLFW_OPENGL_SINGLE_GLRC)
|
||||||
|
endif()
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Set compiler specific flags
|
# Set compiler specific flags
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -237,8 +237,15 @@ static void destroyContextGLX(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (window->context.glx.handle)
|
if (window->context.glx.handle)
|
||||||
|
{
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if (window->context.customctx)
|
||||||
{
|
{
|
||||||
glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
|
glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
|
||||||
|
#endif
|
||||||
window->context.glx.handle = NULL;
|
window->context.glx.handle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -495,6 +502,25 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
|||||||
|
|
||||||
_glfwGrabErrorHandlerX11();
|
_glfwGrabErrorHandlerX11();
|
||||||
|
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if(share)
|
||||||
|
{
|
||||||
|
// Use shared context instead of creating a new one
|
||||||
|
window->context.glx.handle = share;
|
||||||
|
window->context.customctx = GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create new GL render context
|
||||||
|
window->context.glx.handle = NULL;
|
||||||
|
window->context.customctx = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if (!window->context.glx.handle)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
if (_glfw.glx.ARB_create_context)
|
if (_glfw.glx.ARB_create_context)
|
||||||
{
|
{
|
||||||
int index = 0, mask = 0, flags = 0;
|
int index = 0, mask = 0, flags = 0;
|
||||||
@ -602,6 +628,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
|||||||
window->context.glx.handle =
|
window->context.glx.handle =
|
||||||
createLegacyContextGLX(window, native, share);
|
createLegacyContextGLX(window, native, share);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_glfwReleaseErrorHandlerX11();
|
_glfwReleaseErrorHandlerX11();
|
||||||
|
|
||||||
|
@ -340,6 +340,11 @@ struct _GLFWcontext
|
|||||||
int profile;
|
int profile;
|
||||||
int robustness;
|
int robustness;
|
||||||
int release;
|
int release;
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
// Specifies whether this _GLFWcontext has its own GLRC object.
|
||||||
|
// If not, it must not delete the GLRC object on destruction.
|
||||||
|
GLFWbool customctx;
|
||||||
|
#endif
|
||||||
|
|
||||||
PFNGLGETSTRINGIPROC GetStringi;
|
PFNGLGETSTRINGIPROC GetStringi;
|
||||||
PFNGLGETINTEGERVPROC GetIntegerv;
|
PFNGLGETINTEGERVPROC GetIntegerv;
|
||||||
|
@ -57,7 +57,13 @@ static void makeContextCurrentNSGL(_GLFWwindow* window)
|
|||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
|
{
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
[window->context.nsgl.object setView:window->ns.view];
|
||||||
|
[window->context.nsgl.object update];
|
||||||
|
#endif
|
||||||
[window->context.nsgl.object makeCurrentContext];
|
[window->context.nsgl.object makeCurrentContext];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
[NSOpenGLContext clearCurrentContext];
|
[NSOpenGLContext clearCurrentContext];
|
||||||
|
|
||||||
@ -139,7 +145,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];
|
[window->context.nsgl.object release];
|
||||||
|
#else
|
||||||
|
[window->context.nsgl.object release];
|
||||||
|
#endif
|
||||||
window->context.nsgl.object = nil;
|
window->context.nsgl.object = nil;
|
||||||
|
|
||||||
} // autoreleasepool
|
} // autoreleasepool
|
||||||
@ -343,6 +354,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)
|
||||||
@ -351,6 +378,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,
|
||||||
|
@ -388,8 +388,15 @@ static GLFWglproc getProcAddressWGL(const char* procname)
|
|||||||
static void destroyContextWGL(_GLFWwindow* window)
|
static void destroyContextWGL(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->context.wgl.handle)
|
if (window->context.wgl.handle)
|
||||||
|
{
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if (window->context.customctx)
|
||||||
{
|
{
|
||||||
wglDeleteContext(window->context.wgl.handle);
|
wglDeleteContext(window->context.wgl.handle);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
wglDeleteContext(window->context.wgl.handle);
|
||||||
|
#endif
|
||||||
window->context.wgl.handle = NULL;
|
window->context.wgl.handle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -688,9 +695,23 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
|
|
||||||
setAttrib(0, 0);
|
setAttrib(0, 0);
|
||||||
|
|
||||||
window->context.wgl.handle =
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
_glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc,
|
if (share)
|
||||||
share, attribs);
|
{
|
||||||
|
// Use shared context instead of creating a new one
|
||||||
|
window->context.wgl.handle = share;
|
||||||
|
window->context.customctx = GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create new GL render context
|
||||||
|
window->context.wgl.handle = _glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc, NULL, attribs);
|
||||||
|
window->context.customctx = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
window->context.wgl.handle = _glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc, share, attribs);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!window->context.wgl.handle)
|
if (!window->context.wgl.handle)
|
||||||
{
|
{
|
||||||
const DWORD error = GetLastError();
|
const DWORD error = GetLastError();
|
||||||
@ -741,7 +762,23 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
|
if (share)
|
||||||
|
{
|
||||||
|
// Use shared context instead of creating a new one
|
||||||
|
window->context.wgl.handle = share;
|
||||||
|
window->context.customctx = GLFW_FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create new GL render context
|
||||||
window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
|
window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
|
||||||
|
window->context.customctx = GLFW_TRUE;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!window->context.wgl.handle)
|
if (!window->context.wgl.handle)
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
|
_glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
|
||||||
@ -749,6 +786,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _GLFW_OPENGL_SINGLE_GLRC
|
||||||
if (share)
|
if (share)
|
||||||
{
|
{
|
||||||
if (!wglShareLists(share, window->context.wgl.handle))
|
if (!wglShareLists(share, window->context.wgl.handle))
|
||||||
@ -758,6 +796,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
window->context.makeCurrent = makeContextCurrentWGL;
|
window->context.makeCurrent = makeContextCurrentWGL;
|
||||||
|
Loading…
Reference in New Issue
Block a user