[Visualization] Use OpenGL on legacy systems
On legacy OSes, and legacy GPUs, it should use OpenGL and not Metal, otherwise there could be horrible performance, or even crashes. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
c59d4d0215
commit
4b2cf22800
1 changed files with 20 additions and 2 deletions
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#import "SpectrumView.h"
|
#import "SpectrumView.h"
|
||||||
|
|
||||||
|
#import <Metal/Metal.h>
|
||||||
|
|
||||||
#import "analyzer.h"
|
#import "analyzer.h"
|
||||||
|
|
||||||
#define LOWER_BOUND -80
|
#define LOWER_BOUND -80
|
||||||
|
@ -26,6 +28,7 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
BOOL isListening;
|
BOOL isListening;
|
||||||
BOOL bandsReset;
|
BOOL bandsReset;
|
||||||
BOOL cameraControlEnabled;
|
BOOL cameraControlEnabled;
|
||||||
|
BOOL isOpenGL;
|
||||||
|
|
||||||
NSColor *backgroundColor;
|
NSColor *backgroundColor;
|
||||||
ddb_analyzer_t _analyzer;
|
ddb_analyzer_t _analyzer;
|
||||||
|
@ -44,9 +47,20 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
|
|
||||||
- (id)initWithFrame:(NSRect)frame {
|
- (id)initWithFrame:(NSRect)frame {
|
||||||
NSDictionary *sceneOptions = @{
|
NSDictionary *sceneOptions = @{
|
||||||
SCNPreferredRenderingAPIKey: @(SCNRenderingAPIMetal),
|
SCNPreferredRenderingAPIKey: @(SCNRenderingAPIOpenGLCore32)
|
||||||
SCNPreferLowPowerDeviceKey: @(YES)
|
|
||||||
};
|
};
|
||||||
|
isOpenGL = YES;
|
||||||
|
|
||||||
|
if(@available(macOS 10.15, *)) {
|
||||||
|
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
|
||||||
|
if([device supportsFamily:MTLGPUFamilyMac2]) {
|
||||||
|
sceneOptions = @{
|
||||||
|
SCNPreferredRenderingAPIKey: @(SCNRenderingAPIMetal),
|
||||||
|
SCNPreferredDeviceKey: device
|
||||||
|
};
|
||||||
|
isOpenGL = NO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self = [super initWithFrame:frame options:sceneOptions];
|
self = [super initWithFrame:frame options:sceneOptions];
|
||||||
if(self) {
|
if(self) {
|
||||||
|
@ -103,6 +117,8 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
SCNMaterial *material = materials[0];
|
SCNMaterial *material = materials[0];
|
||||||
material.diffuse.contents = barColor;
|
material.diffuse.contents = barColor;
|
||||||
material.emission.contents = barColor;
|
material.emission.contents = barColor;
|
||||||
|
if(isOpenGL)
|
||||||
|
material.emission.intensity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -112,6 +128,8 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
SCNMaterial *material = materials[0];
|
SCNMaterial *material = materials[0];
|
||||||
material.diffuse.contents = dotColor;
|
material.diffuse.contents = dotColor;
|
||||||
material.emission.contents = dotColor;
|
material.emission.contents = dotColor;
|
||||||
|
if(isOpenGL)
|
||||||
|
material.emission.intensity = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue