summaryrefslogtreecommitdiff
path: root/indra/llwindow/llopenglview-objc.mm
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llwindow/llopenglview-objc.mm')
-rw-r--r--indra/llwindow/llopenglview-objc.mm94
1 files changed, 86 insertions, 8 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index c9a62eedb1..57b1252cf1 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -31,6 +31,7 @@
#import <Carbon/Carbon.h>
extern BOOL gHiDPISupport;
+extern BOOL gHDRDisplaySupport;
#pragma mark local functions
@@ -111,6 +112,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
@implementation LLOpenGLView
+- (NSOpenGLContext*) glContext
+{
+ return glContext;
+}
+
+- (NSOpenGLPixelFormat*) pixelFormat
+{
+ return pixelFormat;
+}
+
- (unsigned long)getVramSize
{
CGLRendererInfoObj info = 0;
@@ -135,6 +146,22 @@ attributedStringInfo getSegments(NSAttributedString *str)
return (unsigned long)vram_megabytes; // return value is in megabytes.
}
+- (void)viewWillMoveToWindow:(nullable NSWindow *)newWindow
+{
+ if(mHDRDisplay)
+ {
+ self.wantsExtendedDynamicRangeOpenGLSurface = YES;
+ NSLog(@"Wants Extended Dynamic Range OpenGL", nil);
+ }
+ /*
+ else
+ {
+ self.wantsExtendedDynamicRangeOpenGLSurface = NO;
+ NSLog(@"Wants Standard Color Range OpenGL", nil);
+ }
+ */
+}
+
- (void)viewDidMoveToWindow
{
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -226,22 +253,57 @@ 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[] = {
+
+ NSOpenGLPixelFormatAttribute SDRAttrs[] = {
NSOpenGLPFANoRecovery,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, 0,
- NSOpenGLPFASamples, 0,
- NSOpenGLPFAStencilSize, 8,
+ //NSOpenGLPFASampleBuffers, samples,
+ //NSOpenGLPFASamples, 0,
NSOpenGLPFADepthSize, 24,
- NSOpenGLPFAAlphaSize, 8,
- NSOpenGLPFAColorSize, 24,
+ //NSOpenGLPFAAlphaSize, 8,
+ NSOpenGLPFAColorSize, 32,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
0
};
- NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
+ NSOpenGLPixelFormatAttribute HDRAttrs[] = {
+ NSOpenGLPFANoRecovery,
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFAClosestPolicy,
+ NSOpenGLPFAAccelerated,
+ //NSOpenGLPFASampleBuffers, samples,
+ //NSOpenGLPFASamples, 0,
+ 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
+ {
+ NSLog(@"pixel format created successfully for HDR Display", nil);
+ mHDRDisplay = YES;
+ }
+ }
+ else
+ {
+ pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:SDRAttrs] autorelease];
+ }
if (pixelFormat == nil)
{
@@ -249,7 +311,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
return nil;
}
- NSOpenGLContext *glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
+ glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
if (glContext == nil)
{
@@ -259,6 +321,19 @@ 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);
+
+ NSLog(@"Extended color space applied for HDR Display", nil);
+ }
+
//for retina support
[self setWantsBestResolutionOpenGLSurface:gHiDPISupport];
@@ -280,6 +355,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
[glContext setValues:&swapInterval forParameter:NSOpenGLContextParameterSwapInterval];
}
+ GLint opacity = 1;
+ [glContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity];
+
return self;
}