mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
graphicscommand: Use GL on macOS 10.11 or older (#781)
This commit is contained in:
parent
72c1a73cac
commit
dc0c6e0907
@ -17,6 +17,17 @@
|
||||
|
||||
package graphicscommand
|
||||
|
||||
// #cgo CFLAGS: -x objective-c
|
||||
// #cgo LDFLAGS: -framework Foundation
|
||||
//
|
||||
// #import <Foundation/Foundation.h>
|
||||
//
|
||||
// static int getDarwinMinorVersion() {
|
||||
// NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||
// return (int)version.minorVersion;
|
||||
// }
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal"
|
||||
@ -24,19 +35,28 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
||||
)
|
||||
|
||||
// isMetalSupported represents whether Metal is supported.
|
||||
var isMetalSupported = true
|
||||
var (
|
||||
// isMetalSupported represents whether Metal is supported.
|
||||
isMetalSupported = true
|
||||
|
||||
darwinMajorVersion = 0
|
||||
)
|
||||
|
||||
func init() {
|
||||
// On old mac devices like iMac 2011, Metal is not supported (#779).
|
||||
if _, err := mtl.CreateSystemDefaultDevice(); err != nil {
|
||||
isMetalSupported = false
|
||||
}
|
||||
// On macOS 10.11 El Capitan, there is a rendering issue on Metal (#781).
|
||||
// Use the OpenGL in macOS 10.11 or older.
|
||||
if C.getDarwinMinorVersion() <= 11 {
|
||||
isMetalSupported = false
|
||||
}
|
||||
}
|
||||
|
||||
func Driver() graphicsdriver.GraphicsDriver {
|
||||
if isMetalSupported {
|
||||
return metal.Get()
|
||||
} else {
|
||||
return opengl.Get()
|
||||
}
|
||||
return opengl.Get()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user