mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
macOS: fix colors appearing oversaturated on P3 displays.
The fix only applies to macOS 11+ when using OpenGL.
This commit is contained in:
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
typedef struct SDL_Window SDL_Window;
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
namespace macosx
|
namespace macosx
|
||||||
@@ -55,6 +57,12 @@ std::string getExecutablePath();
|
|||||||
**/
|
**/
|
||||||
void requestAttention(bool continuous);
|
void requestAttention(bool continuous);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly sets the window's color space to be sRGB - which stops the OS
|
||||||
|
* from interpreting the backbuffer output as P3 on P3-capable displays.
|
||||||
|
**/
|
||||||
|
void setWindowSRGBColorSpace(SDL_Window *window);
|
||||||
|
|
||||||
} // macosx
|
} // macosx
|
||||||
} // love
|
} // love
|
||||||
|
|
||||||
|
|||||||
+19
-2
@@ -26,9 +26,11 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#ifdef LOVE_MACOSX_SDL_DIRECT_INCLUDE
|
#ifdef LOVE_MACOSX_SDL_DIRECT_INCLUDE
|
||||||
# include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <SDL_syswm.h>
|
||||||
#else
|
#else
|
||||||
# include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_syswm.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
@@ -93,6 +95,21 @@ void requestAttention(bool continuous)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setWindowSRGBColorSpace(SDL_Window *window)
|
||||||
|
{
|
||||||
|
@autoreleasepool
|
||||||
|
{
|
||||||
|
// This works on earlier macOS versions, but performance may be worse
|
||||||
|
// (at least, it was back when I tested in December 2016).
|
||||||
|
if (@available(macOS 11.0, *))
|
||||||
|
{
|
||||||
|
SDL_SysWMinfo info = {};
|
||||||
|
if (SDL_GetWindowWMInfo(window, &info))
|
||||||
|
info.info.cocoa.window.colorSpace = [NSColorSpace sRGBColorSpace];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // osx
|
} // osx
|
||||||
} // love
|
} // love
|
||||||
|
|
||||||
|
|||||||
@@ -311,6 +311,10 @@ bool Window::createWindowAndContext(int x, int y, int w, int h, Uint32 windowfla
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOVE_MACOS
|
||||||
|
love::macos::setWindowSRGBColorSpace(window);
|
||||||
|
#endif
|
||||||
|
|
||||||
context = SDL_GL_CreateContext(window);
|
context = SDL_GL_CreateContext(window);
|
||||||
|
|
||||||
if (!context)
|
if (!context)
|
||||||
|
|||||||
Reference in New Issue
Block a user