diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 4be29de9a..5705ae395 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -767,6 +767,11 @@ extern "C" { * Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER). */ #define GLFW_DOUBLEBUFFER 0x00021010 +/*! @brief Graphics switching hint. + * + * Graphics switching [hint](@ref GLFW_ALLOW_GRAPHICS_SWITCHING). + */ +#define GLFW_ALLOW_GRAPHICS_SWITCHING 0x00021011 /*! @brief Context client API hint and attribute. * * Context client API [hint](@ref GLFW_CLIENT_API_hint) and diff --git a/src/internal.h b/src/internal.h index cf14b7df2..86753e513 100644 --- a/src/internal.h +++ b/src/internal.h @@ -321,6 +321,7 @@ struct _GLFWfbconfig int samples; GLFWbool sRGB; GLFWbool doublebuffer; + GLFWbool graphicsSwitching; uintptr_t handle; }; diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 76042b40d..941cbb46a 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -231,6 +231,9 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, if (fbconfig->doublebuffer) ADD_ATTR(kCGLPFADoubleBuffer); + if (fbconfig->graphicsSwitching) + ADD_ATTR(kCGLPFASupportsAutomaticGraphicsSwitching); + if (fbconfig->samples != GLFW_DONT_CARE) { if (fbconfig->samples == 0) diff --git a/src/window.c b/src/window.c index f6d71b680..2562f43d6 100644 --- a/src/window.c +++ b/src/window.c @@ -263,6 +263,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.framebuffer.depthBits = 24; _glfw.hints.framebuffer.stencilBits = 8; _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE; + _glfw.hints.framebuffer.graphicsSwitching = GLFW_FALSE; // The default is to select the highest available refresh rate _glfw.hints.refreshRate = GLFW_DONT_CARE; @@ -316,6 +317,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_DOUBLEBUFFER: _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE; break; + case GLFW_ALLOW_GRAPHICS_SWITCHING: + _glfw.hints.framebuffer.graphicsSwitching = value ? GLFW_TRUE : GLFW_FALSE; + break; case GLFW_SAMPLES: _glfw.hints.framebuffer.samples = value; break;