mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Add GLFW_COCOA_GRAPHICS_SWICTHING
This provides control over whether the context should participate in macOS Automatic Graphics Switching. Closes #377. Closes #935.
This commit is contained in:
parent
4250725a60
commit
77a8f103d8
@ -133,6 +133,7 @@ information on what to include when reporting a bug.
|
|||||||
(#749,#842)
|
(#749,#842)
|
||||||
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
|
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
|
||||||
- Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195)
|
- Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195)
|
||||||
|
- Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935)
|
||||||
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
|
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
|
||||||
- Removed `GLFW_USE_RETINA` compile-time option
|
- Removed `GLFW_USE_RETINA` compile-time option
|
||||||
- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored
|
- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored
|
||||||
@ -236,6 +237,7 @@ skills.
|
|||||||
- Cameron King
|
- Cameron King
|
||||||
- Peter Knut
|
- Peter Knut
|
||||||
- Christoph Kubisch
|
- Christoph Kubisch
|
||||||
|
- Konstantin Käfer
|
||||||
- Eric Larson
|
- Eric Larson
|
||||||
- Robin Leffmann
|
- Robin Leffmann
|
||||||
- Glenn Lewis
|
- Glenn Lewis
|
||||||
|
@ -421,6 +421,23 @@ __GLFW_COCOA_FRAME_AUTOSAVE__ specifies whether to activate frame autosaving
|
|||||||
using the window title specified at window creation. This is ignored on other
|
using the window title specified at window creation. This is ignored on other
|
||||||
platforms.
|
platforms.
|
||||||
|
|
||||||
|
@anchor GLFW_COCOA_GRAPHICS_SWITCHING_hint
|
||||||
|
__GLFW_COCOA_GRAPHICS_SWITCHING__ specifies whether to in Automatic Graphics
|
||||||
|
Switching, i.e. to allow the system to choose the integrated GPU for the OpenGL
|
||||||
|
context and move it between GPUs if necessary or whether to force it to always
|
||||||
|
run on the discrete GPU. This only affects systems with both integrated and
|
||||||
|
discrete GPUs. This is ignored on other platforms.
|
||||||
|
|
||||||
|
@par
|
||||||
|
Simpler programs and tools may want to enable this to save power, while games
|
||||||
|
and other applications performing advanced rendering will want to leave it
|
||||||
|
disabled.
|
||||||
|
|
||||||
|
@par
|
||||||
|
A bundled application that wishes to participate in Automatic Graphics Switching
|
||||||
|
should also declare this in its `Info.plist` by setting the
|
||||||
|
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_hints_values Supported and default values
|
@subsubsection window_hints_values Supported and default values
|
||||||
|
|
||||||
@ -461,6 +478,7 @@ GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GL
|
|||||||
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
||||||
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_COCOA_FRAME_AUTOSAVE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_FRAME_AUTOSAVE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
|
||||||
|
|
||||||
@section window_events Window event processing
|
@section window_events Window event processing
|
||||||
|
@ -852,6 +852,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
|
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
|
||||||
#define GLFW_COCOA_FRAME_AUTOSAVE 0x00023002
|
#define GLFW_COCOA_FRAME_AUTOSAVE 0x00023002
|
||||||
|
#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_NO_API 0
|
#define GLFW_NO_API 0
|
||||||
|
@ -340,6 +340,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
|
|
||||||
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
|
||||||
{
|
{
|
||||||
|
_GLFWwindow* window;
|
||||||
|
|
||||||
|
for (window = _glfw.windowListHead; window; window = window->next)
|
||||||
|
{
|
||||||
|
if (window->context.client != GLFW_NO_API)
|
||||||
|
[window->context.nsgl.object update];
|
||||||
|
}
|
||||||
|
|
||||||
_glfwPollMonitorsNS();
|
_glfwPollMonitorsNS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,6 +303,9 @@ struct _GLFWctxconfig
|
|||||||
int robustness;
|
int robustness;
|
||||||
int release;
|
int release;
|
||||||
_GLFWwindow* share;
|
_GLFWwindow* share;
|
||||||
|
struct {
|
||||||
|
GLFWbool offline;
|
||||||
|
} nsgl;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! @brief Framebuffer configuration.
|
/*! @brief Framebuffer configuration.
|
||||||
|
@ -160,6 +160,18 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||||||
ADD_ATTR(NSOpenGLPFAAccelerated);
|
ADD_ATTR(NSOpenGLPFAAccelerated);
|
||||||
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
||||||
|
|
||||||
|
if (ctxconfig->nsgl.offline)
|
||||||
|
{
|
||||||
|
ADD_ATTR(NSOpenGLPFAAllowOfflineRenderers);
|
||||||
|
// NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
|
||||||
|
// Info.plist for unbundled applications
|
||||||
|
// HACK: This assumes that NSOpenGLPixelFormat will remain
|
||||||
|
// a straightforward wrapper of its CGL counterpart
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 100800
|
||||||
|
ADD_ATTR(kCGLPFASupportsAutomaticGraphicsSwitching);
|
||||||
|
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||||
|
}
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||||
if (ctxconfig->major >= 4)
|
if (ctxconfig->major >= 4)
|
||||||
{
|
{
|
||||||
|
@ -345,6 +345,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
|||||||
case GLFW_COCOA_FRAME_AUTOSAVE:
|
case GLFW_COCOA_FRAME_AUTOSAVE:
|
||||||
_glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
break;
|
break;
|
||||||
|
case GLFW_COCOA_GRAPHICS_SWITCHING:
|
||||||
|
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
|
break;
|
||||||
case GLFW_CENTER_CURSOR:
|
case GLFW_CENTER_CURSOR:
|
||||||
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user