OpenGL fallback

This commit is contained in:
Lior Halphon 2018-06-15 20:03:59 +03:00
parent a068b7b09f
commit 1c1cddb53e
4 changed files with 14 additions and 3 deletions

View File

@ -26,8 +26,11 @@
+ (instancetype)allocWithZone:(struct _NSZone *)zone + (instancetype)allocWithZone:(struct _NSZone *)zone
{ {
if (self == [GBView class]) { if (self == [GBView class]) {
if ([GBViewMetal isSupported]) {
return [GBViewMetal allocWithZone: zone]; return [GBViewMetal allocWithZone: zone];
} }
return [GBViewGL allocWithZone: zone];
}
return [super allocWithZone:zone]; return [super allocWithZone:zone];
} }

View File

@ -3,5 +3,5 @@
#import "GBView.h" #import "GBView.h"
@interface GBViewMetal : GBView<MTKViewDelegate> @interface GBViewMetal : GBView<MTKViewDelegate>
+ (bool) isSupported;
@end @end

View File

@ -29,6 +29,14 @@ static const vector_float2 rect[] =
vector_float2 output_resolution; vector_float2 output_resolution;
} }
+ (bool)isSupported
{
if (MTLCopyAllDevices) {
return [MTLCopyAllDevices() count];
}
return false;
}
- (void)createInternalView - (void)createInternalView
{ {
MTKView *view = [[MTKView alloc] initWithFrame:self.frame device:(device = MTLCreateSystemDefaultDevice())]; MTKView *view = [[MTKView alloc] initWithFrame:self.frame device:(device = MTLCreateSystemDefaultDevice())];

View File

@ -61,7 +61,7 @@ ifeq ($(PLATFORM),Darwin)
SYSROOT := $(shell xcodebuild -sdk macosx -version Path 2> /dev/null) SYSROOT := $(shell xcodebuild -sdk macosx -version Path 2> /dev/null)
CFLAGS += -F/Library/Frameworks CFLAGS += -F/Library/Frameworks
OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT) -mmacosx-version-min=10.9 OCFLAGS += -x objective-c -fobjc-arc -Wno-deprecated-declarations -isysroot $(SYSROOT) -mmacosx-version-min=10.9
LDFLAGS += -framework AppKit -framework PreferencePanes -framework Carbon -framework QuartzCore -framework Metal -framework MetalKit LDFLAGS += -framework AppKit -framework PreferencePanes -framework Carbon -framework QuartzCore -weak_framework Metal -weak_framework MetalKit
SDL_LDFLAGS := -F/Library/Frameworks -framework SDL2 -framework OpenGL SDL_LDFLAGS := -F/Library/Frameworks -framework SDL2 -framework OpenGL
endif endif
CFLAGS += -Wno-deprecated-declarations CFLAGS += -Wno-deprecated-declarations