mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ebiten: refactoring: move the caller of SetGraphicsDriver to the package ui
This commit is contained in:
parent
df60c4c92d
commit
f18aef2b08
@ -34,6 +34,8 @@ package ui
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
||||||
@ -56,14 +58,15 @@ func supportsMetal() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
var graphicsOnce sync.Once
|
||||||
if supportsMetal() {
|
|
||||||
graphics = metal.Get()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
graphics = opengl.Get()
|
|
||||||
}
|
|
||||||
|
|
||||||
func Graphics() graphicsdriver.Graphics {
|
func Graphics() graphicsdriver.Graphics {
|
||||||
|
graphicsOnce.Do(func() {
|
||||||
|
if supportsMetal() {
|
||||||
|
graphics = metal.Get()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
graphics = opengl.Get()
|
||||||
|
})
|
||||||
return graphics
|
return graphics
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,12 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package ebiten
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
||||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
graphicscommand.SetGraphicsDriver(ui.Graphics())
|
graphicscommand.SetGraphicsDriver(Graphics())
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user