macOS: fix colors appearing oversaturated on P3 displays.

The fix only applies to macOS 11+ when using OpenGL.
This commit is contained in:
slime
2022-09-30 15:17:46 -03:00
parent 60036d5dfe
commit 6173c1638d
4 changed files with 49 additions and 28 deletions
-6
View File
@@ -479,12 +479,6 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int
metalLayer.device = device;
metalLayer.pixelFormat = isGammaCorrect() ? MTLPixelFormatBGRA8Unorm_sRGB : MTLPixelFormatBGRA8Unorm;
// Explicitly turn off color matching, for now (eg don't make sRGB content
// appear correct on P3 displays). It looks better with color matching, but
// having it off matches the OpenGL backend and there's some cost to it.
// TODO: revisit this?
metalLayer.colorspace = nil;
// This is set to NO when there are pending screen captures.
metalLayer.framebufferOnly = YES;
+21 -19
View File
@@ -366,27 +366,29 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
return false;
}
if (renderer == love::graphics::Renderer::RENDERER_OPENGL) {
if (attribs != nullptr)
if (attribs != nullptr && renderer == love::graphics::Renderer::RENDERER_OPENGL)
{
#ifdef LOVE_MACOS
love::macos::setWindowSRGBColorSpace(window);
#endif
glcontext = SDL_GL_CreateContext(window);
if (!glcontext)
contexterror = std::string(SDL_GetError());
// Make sure the context's version is at least what we requested.
if (glcontext && !checkGLVersion(*attribs, glversion))
{
glcontext = SDL_GL_CreateContext(window);
SDL_GL_DeleteContext(glcontext);
glcontext = nullptr;
}
if (!glcontext)
contexterror = std::string(SDL_GetError());
// Make sure the context's version is at least what we requested.
if (glcontext && !checkGLVersion(*attribs, glversion))
{
SDL_GL_DeleteContext(glcontext);
glcontext = nullptr;
}
if (!glcontext)
{
SDL_DestroyWindow(window);
window = nullptr;
return false;
}
if (!glcontext)
{
SDL_DestroyWindow(window);
window = nullptr;
return false;
}
}