From 024fc48647c2eff97f490914ad877f5a784982af Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Tue, 11 Feb 2020 11:14:19 +0900 Subject: [PATCH] Refactoring: Add init.go --- init.go | 29 +++++++++++++++++++++++++++++ run.go | 2 -- uicontext.go | 9 --------- 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 init.go diff --git a/init.go b/init.go new file mode 100644 index 000000000..5e912839c --- /dev/null +++ b/init.go @@ -0,0 +1,29 @@ +// Copyright 2020 The Ebiten Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ebiten + +import ( + "github.com/hajimehoshi/ebiten/internal/graphicscommand" + "github.com/hajimehoshi/ebiten/internal/mipmap" + "github.com/hajimehoshi/ebiten/internal/shareable" +) + +var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__ + +func init() { + mipmap.SetGraphicsDriver(uiDriver().Graphics()) + shareable.SetGraphicsDriver(uiDriver().Graphics()) + graphicscommand.SetGraphicsDriver(uiDriver().Graphics()) +} diff --git a/run.go b/run.go index d1dca4130..408a25dc9 100644 --- a/run.go +++ b/run.go @@ -21,8 +21,6 @@ import ( "github.com/hajimehoshi/ebiten/internal/driver" ) -var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__ - // Game defines necessary functions for a game. type Game interface { // Update updates a game by one frame. diff --git a/uicontext.go b/uicontext.go index dd7582242..fe8bdfa87 100644 --- a/uicontext.go +++ b/uicontext.go @@ -23,18 +23,9 @@ import ( "github.com/hajimehoshi/ebiten/internal/buffered" "github.com/hajimehoshi/ebiten/internal/clock" "github.com/hajimehoshi/ebiten/internal/driver" - "github.com/hajimehoshi/ebiten/internal/graphicscommand" "github.com/hajimehoshi/ebiten/internal/hooks" - "github.com/hajimehoshi/ebiten/internal/mipmap" - "github.com/hajimehoshi/ebiten/internal/shareable" ) -func init() { - mipmap.SetGraphicsDriver(uiDriver().Graphics()) - shareable.SetGraphicsDriver(uiDriver().Graphics()) - graphicscommand.SetGraphicsDriver(uiDriver().Graphics()) -} - type defaultGame struct { update func(screen *Image) error width int