mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphicsdriver/metal: Avoid using @available syntax for old Xcode (#781)
This commit is contained in:
parent
802f3cfe3d
commit
72c1a73cac
@ -28,7 +28,10 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #cgo CFLAGS: -mmacosx-version-min=10.11
|
// Suppress the warnings about availability guard with -Wno-unguarded-availability-new.
|
||||||
|
// It is because old Xcode (8 or older?) does not accept @available syntax.
|
||||||
|
|
||||||
|
// #cgo CFLAGS: -mmacosx-version-min=10.11 -Wno-unguarded-availability-new
|
||||||
// #cgo LDFLAGS: -framework QuartzCore -framework Foundation -framework CoreGraphics
|
// #cgo LDFLAGS: -framework QuartzCore -framework Foundation -framework CoreGraphics
|
||||||
//
|
//
|
||||||
// #include "ca.h"
|
// #include "ca.h"
|
||||||
|
@ -46,7 +46,12 @@ const char *MetalLayer_SetPixelFormat(void *metalLayer, uint16_t pixelFormat) {
|
|||||||
|
|
||||||
const char *MetalLayer_SetMaximumDrawableCount(void *metalLayer,
|
const char *MetalLayer_SetMaximumDrawableCount(void *metalLayer,
|
||||||
uint_t maximumDrawableCount) {
|
uint_t maximumDrawableCount) {
|
||||||
if (@available(macOS 10.13.2, *)) {
|
// @available syntax is not available for old Xcode (#781)
|
||||||
|
//
|
||||||
|
// If possible, we'd want to write the guard like:
|
||||||
|
//
|
||||||
|
// if (@available(macOS 10.13.2, *)) { ...
|
||||||
|
|
||||||
@try {
|
@try {
|
||||||
if ([(CAMetalLayer *)metalLayer
|
if ([(CAMetalLayer *)metalLayer
|
||||||
respondsToSelector:@selector(setMaximumDrawableCount:)]) {
|
respondsToSelector:@selector(setMaximumDrawableCount:)]) {
|
||||||
@ -56,19 +61,22 @@ const char *MetalLayer_SetMaximumDrawableCount(void *metalLayer,
|
|||||||
} @catch (NSException *exception) {
|
} @catch (NSException *exception) {
|
||||||
return exception.reason.UTF8String;
|
return exception.reason.UTF8String;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetalLayer_SetDisplaySyncEnabled(void *metalLayer,
|
void MetalLayer_SetDisplaySyncEnabled(void *metalLayer,
|
||||||
BOOL displaySyncEnabled) {
|
BOOL displaySyncEnabled) {
|
||||||
if (@available(macOS 10.13, *)) {
|
// @available syntax is not available for old Xcode (#781)
|
||||||
|
//
|
||||||
|
// If possible, we'd want to write the guard like:
|
||||||
|
//
|
||||||
|
// if (@available(macOS 10.13, *)) { ...
|
||||||
|
|
||||||
if ([(CAMetalLayer *)metalLayer
|
if ([(CAMetalLayer *)metalLayer
|
||||||
respondsToSelector:@selector(setDisplaySyncEnabled:)]) {
|
respondsToSelector:@selector(setDisplaySyncEnabled:)]) {
|
||||||
[((CAMetalLayer *)metalLayer) setDisplaySyncEnabled:displaySyncEnabled];
|
[((CAMetalLayer *)metalLayer) setDisplaySyncEnabled:displaySyncEnabled];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height) {
|
void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height) {
|
||||||
((CAMetalLayer *)metalLayer).drawableSize = (CGSize){width, height};
|
((CAMetalLayer *)metalLayer).drawableSize = (CGSize){width, height};
|
||||||
|
Loading…
Reference in New Issue
Block a user