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 (
|
||||
"sync"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver/metal/mtl"
|
||||
@ -56,14 +58,15 @@ func supportsMetal() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func init() {
|
||||
if supportsMetal() {
|
||||
graphics = metal.Get()
|
||||
return
|
||||
}
|
||||
graphics = opengl.Get()
|
||||
}
|
||||
var graphicsOnce sync.Once
|
||||
|
||||
func Graphics() graphicsdriver.Graphics {
|
||||
graphicsOnce.Do(func() {
|
||||
if supportsMetal() {
|
||||
graphics = metal.Get()
|
||||
return
|
||||
}
|
||||
graphics = opengl.Get()
|
||||
})
|
||||
return graphics
|
||||
}
|
||||
|
@ -12,13 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ebiten
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/graphicscommand"
|
||||
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||
)
|
||||
|
||||
func init() {
|
||||
graphicscommand.SetGraphicsDriver(ui.Graphics())
|
||||
graphicscommand.SetGraphicsDriver(Graphics())
|
||||
}
|
Loading…
Reference in New Issue
Block a user