diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 4388778f8..0366af24a 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1731,7 +1731,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!createNativeWindow(window, wndconfig, fbconfig)) return false; - [window->ns.object setColorSpace:[NSColorSpace sRGBColorSpace]]; + switch((GlfwCocoaColorSpaces)wndconfig->ns.color_space) { + case SRGB_COLORSPACE: [window->ns.object setColorSpace:[NSColorSpace sRGBColorSpace]]; break; + case DISPLAY_P3_COLORSPACE: [window->ns.object setColorSpace:[NSColorSpace displayP3ColorSpace]]; break; + case DEFAULT_COLORSPACE: break; + } if (ctxconfig->client != GLFW_NO_API) { diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 3f10e1e18..311490d47 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1024,6 +1024,16 @@ typedef enum GLFWMouseButton { * [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint). */ #define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003 +/*! @brief macOS specific + * [window hint](@ref GLFW_COCOA_COLOR_SPACE_hint). + */ +#define GLFW_COCOA_COLOR_SPACE 0x00023004 +typedef enum { + DEFAULT_COLORSPACE = 0, + SRGB_COLORSPACE = 1, + DISPLAY_P3_COLORSPACE = 2, +} GlfwCocoaColorSpaces; + /*! @brief X11 specific * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ diff --git a/glfw/internal.h b/glfw/internal.h index 7e7c76c76..822d3d356 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -307,6 +307,7 @@ struct _GLFWwndconfig bool scaleToMonitor; struct { bool retina; + int color_space; char frameName[256]; } ns; struct { diff --git a/glfw/window.c b/glfw/window.c index b69300e2b..60f9820ad 100644 --- a/glfw/window.c +++ b/glfw/window.c @@ -332,6 +332,8 @@ void glfwDefaultWindowHints(void) // The default is to use full Retina resolution framebuffers _glfw.hints.window.ns.retina = true; + // use the default colorspace assigned by the system + _glfw.hints.window.ns.color_space = 0; } GLFWAPI void glfwWindowHint(int hint, int value) @@ -412,6 +414,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_RETINA_FRAMEBUFFER: _glfw.hints.window.ns.retina = value ? true : false; return; + case GLFW_COCOA_COLOR_SPACE: + _glfw.hints.window.ns.color_space = value; + return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? true : false; return;