Cocoa: Allow opting in to graphics switching on macOS

This commit is contained in:
Konstantin Käfer 2017-01-25 12:15:04 +01:00
parent 70f8d1fd3d
commit 9ee2070c59
4 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -321,6 +321,7 @@ struct _GLFWfbconfig
int samples;
GLFWbool sRGB;
GLFWbool doublebuffer;
GLFWbool graphicsSwitching;
uintptr_t handle;
};

View File

@ -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)

View File

@ -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;