summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llopenglview-objc.h2
-rw-r--r--indra/llwindow/llopenglview-objc.mm75
-rw-r--r--indra/llwindow/llwindowmacosx.cpp1
3 files changed, 62 insertions, 16 deletions
diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h
index 97f4125484..fabce18b6a 100644
--- a/indra/llwindow/llopenglview-objc.h
+++ b/indra/llwindow/llopenglview-objc.h
@@ -43,6 +43,8 @@
bool mMarkedTextAllowed;
bool mSimulatedRightClick;
bool mOldResize;
+
+ bool mHDRDisplay;
}
- (id) initWithSamples:(NSUInteger)samples;
- (id) initWithSamples:(NSUInteger)samples andVsync:(BOOL)vsync;
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 3cb6686c02..577311bf49 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -29,6 +29,7 @@
#import "llappdelegate-objc.h"
extern BOOL gHiDPISupport;
+extern BOOL gHDRDisplaySupport;
#pragma mark local functions
@@ -157,6 +158,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
return (unsigned long)vram_megabytes; // return value is in megabytes.
}
+- (void)viewWillMoveToWindow:(nullable NSWindow *)newWindow
+{
+ if(mHDRDisplay) self.wantsExtendedDynamicRangeOpenGLSurface = YES;
+ //else self.wantsExtendedDynamicRangeOpenGLSurface = NO;
+}
+
- (void)viewDidMoveToWindow
{
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -250,22 +257,47 @@ attributedStringInfo getSegments(NSAttributedString *str)
// Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6.
// Any specialized pixel formats, i.e. a core profile pixel format, should be initialized through rebuildContextWithFormat.
// 10.7 and 10.8 don't really care if we're defining a profile or not. If we don't explicitly request a core or legacy profile, it'll always assume a legacy profile (for compatibility reasons).
- NSOpenGLPixelFormatAttribute attrs[] = {
- NSOpenGLPFANoRecovery,
- NSOpenGLPFADoubleBuffer,
- NSOpenGLPFAClosestPolicy,
- NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, 0,
- NSOpenGLPFASamples, 0,
- NSOpenGLPFAStencilSize, 8,
- NSOpenGLPFADepthSize, 24,
- NSOpenGLPFAAlphaSize, 8,
- NSOpenGLPFAColorSize, 24,
- NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
- 0
- };
-
- NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
+ NSOpenGLPixelFormatAttribute SDRAttrs[] = {
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFASampleBuffers, 0,
+ NSOpenGLPFASamples, 0,
+ NSOpenGLPFAStencilSize, 8,
+ NSOpenGLPFADepthSize, 24,
+ NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
+ 0};
+
+ NSOpenGLPixelFormatAttribute HDRAttrs[] = {
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFASampleBuffers, 0,
+ NSOpenGLPFASamples, 0,
+ NSOpenGLPFAStencilSize, 8,
+ NSOpenGLPFAColorFloat,
+ NSOpenGLPFAColorSize, 64,
+ NSOpenGLPFADepthSize, 24,
+ NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
+ 0};
+
+ NSOpenGLPixelFormat *pixelFormat = nil;
+
+ mHDRDisplay = NO;
+
+ if(gHDRDisplaySupport)
+ {
+ pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:HDRAttrs] autorelease];
+ if (pixelFormat == nil)
+ {
+ NSLog(@"Failed to create pixel format for HDR Display!", nil);
+ pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:SDRAttrs] autorelease];
+ }
+ else
+ {
+ mHDRDisplay = YES;
+ }
+ }
+ else
+ {
+ pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:SDRAttrs] autorelease];
+ }
if (pixelFormat == nil)
{
@@ -283,6 +315,17 @@ attributedStringInfo getSegments(NSAttributedString *str)
[self setPixelFormat:pixelFormat];
+ if(mHDRDisplay)
+ {
+ CGColorSpaceRef color_space = [self.window.colorSpace CGColorSpace];
+ CGColorSpaceRef color_space_extended = CGColorSpaceCreateExtended(color_space);
+ NSColorSpace* extended_ns_color_space
+ = [[NSColorSpace alloc] initWithCGColorSpace:color_space_extended];
+
+ self.window.colorSpace = extended_ns_color_space;
+ CGColorSpaceRelease(color_space_extended);
+ }
+
//for retina support
[self setWantsBestResolutionOpenGLSurface:gHiDPISupport];
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index c97e014e46..febb43a49b 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -53,6 +53,7 @@
extern bool gDebugWindowProc;
bool gHiDPISupport = true;
+bool gHDRDisplaySupport = false;
const S32 BITS_PER_PIXEL = 32;
const S32 MAX_NUM_RESOLUTIONS = 32;