mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 13:46:37 +00:00
Added option 'GLFW_OPENGL_SINGLE_GLRC' to make GLFW use only a single GLRC.
This commit is contained in:
parent
0a3c4f5d80
commit
fe890e5e26
@ -30,6 +30,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)
|
||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF)
|
option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF)
|
||||||
@ -73,6 +74,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
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
|
@ -341,6 +341,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;
|
||||||
|
@ -323,8 +323,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,9 +630,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();
|
||||||
|
Loading…
Reference in New Issue
Block a user