mirror of
https://github.com/glfw/glfw.git
synced 2025-10-03 21:30:57 +00:00
Added ability to reuse a context of another window instead of creating a new one with sharing (implementation only for Windows).
This commit is contained in:
parent
9040c64e5b
commit
98557d0f89
@ -623,6 +623,7 @@ extern "C" {
|
||||
#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007
|
||||
#define GLFW_OPENGL_PROFILE 0x00022008
|
||||
#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
|
||||
#define GLFW_REUSE_CONTEXT 0x0002200A
|
||||
|
||||
#define GLFW_OPENGL_API 0x00030001
|
||||
#define GLFW_OPENGL_ES_API 0x00030002
|
||||
|
@ -189,6 +189,7 @@ struct _GLFWctxconfig
|
||||
int robustness;
|
||||
int release;
|
||||
_GLFWwindow* share;
|
||||
int reuseContext;
|
||||
};
|
||||
|
||||
|
||||
@ -353,6 +354,7 @@ struct _GLFWlibrary
|
||||
int profile;
|
||||
int robustness;
|
||||
int release;
|
||||
int reuseContext;
|
||||
} hints;
|
||||
|
||||
double cursorPosX, cursorPosY;
|
||||
|
@ -338,7 +338,11 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (window->wgl.ARB_create_context)
|
||||
if (share && ctxconfig->reuseContext)
|
||||
{
|
||||
window->wgl.context = share;
|
||||
}
|
||||
else if (window->wgl.ARB_create_context)
|
||||
{
|
||||
int index = 0, mask = 0, flags = 0;
|
||||
|
||||
|
@ -171,6 +171,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
ctxconfig.robustness = _glfw.hints.robustness;
|
||||
ctxconfig.release = _glfw.hints.release;
|
||||
ctxconfig.share = (_GLFWwindow*) share;
|
||||
ctxconfig.reuseContext = _glfw.hints.reuseContext;
|
||||
|
||||
// Check the OpenGL bits of the window config
|
||||
if (!_glfwIsValidContextConfig(&ctxconfig))
|
||||
@ -295,6 +296,7 @@ void glfwDefaultWindowHints(void)
|
||||
_glfw.hints.depthBits = 24;
|
||||
_glfw.hints.stencilBits = 8;
|
||||
_glfw.hints.doublebuffer = GL_TRUE;
|
||||
_glfw.hints.reuseContext = GL_FALSE;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
@ -393,6 +395,8 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
|
||||
_glfw.hints.release = hint;
|
||||
break;
|
||||
case GLFW_REUSE_CONTEXT:
|
||||
_glfw.hints.reuseContext = hint;
|
||||
default:
|
||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint");
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user