Refactoring: Add init.go

This commit is contained in:
Hajime Hoshi 2020-02-11 11:14:19 +09:00
parent 099ce1b3b4
commit 024fc48647
3 changed files with 29 additions and 11 deletions

29
init.go Normal file
View File

@ -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())
}

2
run.go
View File

@ -21,8 +21,6 @@ import (
"github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/driver"
) )
var _ = __EBITEN_REQUIRES_GO_VERSION_1_12_OR_LATER__
// Game defines necessary functions for a game. // Game defines necessary functions for a game.
type Game interface { type Game interface {
// Update updates a game by one frame. // Update updates a game by one frame.

View File

@ -23,18 +23,9 @@ import (
"github.com/hajimehoshi/ebiten/internal/buffered" "github.com/hajimehoshi/ebiten/internal/buffered"
"github.com/hajimehoshi/ebiten/internal/clock" "github.com/hajimehoshi/ebiten/internal/clock"
"github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
"github.com/hajimehoshi/ebiten/internal/hooks" "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 { type defaultGame struct {
update func(screen *Image) error update func(screen *Image) error
width int width int