graphicscommand: Use Opengl instead on early MacOSX platform which does not support Metal (#779)

This commit is contained in:
mebusy 2019-01-11 21:34:23 +08:00 committed by Hajime Hoshi
parent 6783aaae56
commit 0419aec617

View File

@ -20,8 +20,23 @@ package graphicscommand
import ( import (
"github.com/hajimehoshi/ebiten/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/internal/graphicsdriver"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
) )
func Driver() graphicsdriver.GraphicsDriver { // isMetalSupported represents whether Metal is supported.
return metal.Get() var isMetalSupported = true
func init() {
if _, err := mtl.CreateSystemDefaultDevice(); err != nil {
isMetalSupported = false
}
}
func Driver() graphicsdriver.GraphicsDriver {
if isMetalSupported {
return metal.Get()
} else {
return opengl.Get()
}
} }