mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Create packages drivers having actual drivers
This commit is contained in:
parent
92193b2362
commit
5e38f81462
@ -19,7 +19,7 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
||||
"github.com/hajimehoshi/ebiten/internal/drivers"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/internal/shareable"
|
||||
@ -123,7 +123,7 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
||||
|
||||
op := &DrawImageOptions{}
|
||||
|
||||
switch vd := graphicscommand.Driver().VDirection(); vd {
|
||||
switch vd := drivers.Graphics().VDirection(); vd {
|
||||
case graphicsdriver.VDownward:
|
||||
// c.screen is special: its Y axis is down to up,
|
||||
// and the origin point is lower left.
|
||||
|
@ -15,7 +15,7 @@
|
||||
// +build darwin,!ios
|
||||
// +build !js
|
||||
|
||||
package graphicscommand
|
||||
package drivers
|
||||
|
||||
// #cgo CFLAGS: -x objective-c
|
||||
// #cgo LDFLAGS: -framework Foundation
|
||||
@ -52,7 +52,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func Driver() graphicsdriver.GraphicsDriver {
|
||||
func Graphics() graphicsdriver.GraphicsDriver {
|
||||
if isMetalSupported {
|
||||
return metal.Get()
|
||||
}
|
@ -14,13 +14,13 @@
|
||||
|
||||
// +build !darwin ios js
|
||||
|
||||
package graphicscommand
|
||||
package drivers
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
||||
)
|
||||
|
||||
func Driver() graphicsdriver.GraphicsDriver {
|
||||
func Graphics() graphicsdriver.GraphicsDriver {
|
||||
return opengl.Get()
|
||||
}
|
@ -18,6 +18,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||
"github.com/hajimehoshi/ebiten/internal/drivers"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
)
|
||||
|
||||
@ -166,7 +167,7 @@ func (q *commandQueue) Flush() {
|
||||
nc++
|
||||
}
|
||||
if 0 < ne {
|
||||
Driver().SetVertices(vs[:nv], es[:ne])
|
||||
drivers.Graphics().SetVertices(vs[:nv], es[:ne])
|
||||
es = es[ne:]
|
||||
vs = vs[nv:]
|
||||
}
|
||||
@ -186,7 +187,7 @@ func (q *commandQueue) Flush() {
|
||||
}
|
||||
if 0 < nc {
|
||||
// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
|
||||
Driver().Flush()
|
||||
drivers.Graphics().Flush()
|
||||
}
|
||||
q.commands = q.commands[nc:]
|
||||
}
|
||||
@ -232,7 +233,7 @@ func (c *drawImageCommand) Exec(indexOffset int) error {
|
||||
|
||||
c.dst.image.SetAsDestination()
|
||||
c.src.image.SetAsSource()
|
||||
if err := Driver().Draw(c.nindices, indexOffset, c.mode, c.color, c.filter, c.address); err != nil {
|
||||
if err := drivers.Graphics().Draw(c.nindices, indexOffset, c.mode, c.color, c.filter, c.address); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -438,7 +439,7 @@ func (c *newImageCommand) String() string {
|
||||
|
||||
// Exec executes a newImageCommand.
|
||||
func (c *newImageCommand) Exec(indexOffset int) error {
|
||||
i, err := Driver().NewImage(c.width, c.height)
|
||||
i, err := drivers.Graphics().NewImage(c.width, c.height)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -478,7 +479,7 @@ func (c *newScreenFramebufferImageCommand) String() string {
|
||||
// Exec executes a newScreenFramebufferImageCommand.
|
||||
func (c *newScreenFramebufferImageCommand) Exec(indexOffset int) error {
|
||||
var err error
|
||||
c.result.image, err = Driver().NewScreenFramebufferImage(c.width, c.height)
|
||||
c.result.image, err = drivers.Graphics().NewScreenFramebufferImage(c.width, c.height)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -502,5 +503,5 @@ func (c *newScreenFramebufferImageCommand) CanMerge(dst, src *Image, color *affi
|
||||
|
||||
// ResetGraphicsDriverState resets or initializes the current graphics driver state.
|
||||
func ResetGraphicsDriverState() error {
|
||||
return Driver().Reset()
|
||||
return drivers.Graphics().Reset()
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
||||
"github.com/hajimehoshi/ebiten/internal/drivers"
|
||||
"github.com/hajimehoshi/ebiten/internal/glfw"
|
||||
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||
"github.com/hajimehoshi/ebiten/internal/input"
|
||||
"github.com/hajimehoshi/ebiten/internal/mainthread"
|
||||
@ -99,7 +99,7 @@ func initialize() error {
|
||||
if err := glfw.Init(); err != nil {
|
||||
return err
|
||||
}
|
||||
if !graphicscommand.Driver().IsGL() {
|
||||
if !drivers.Graphics().IsGL() {
|
||||
glfw.WindowHint(glfw.ClientAPI, glfw.NoAPI)
|
||||
}
|
||||
glfw.WindowHint(glfw.Visible, glfw.False)
|
||||
@ -604,7 +604,7 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
|
||||
}
|
||||
u.window = window
|
||||
|
||||
if graphicscommand.Driver().IsGL() {
|
||||
if drivers.Graphics().IsGL() {
|
||||
u.window.MakeContextCurrent()
|
||||
}
|
||||
|
||||
@ -679,7 +679,7 @@ func Run(width, height int, scale float64, title string, g GraphicsContext, main
|
||||
w = u.nativeWindow()
|
||||
return nil
|
||||
})
|
||||
graphicscommand.Driver().SetWindow(w)
|
||||
drivers.Graphics().SetWindow(w)
|
||||
return u.loop(g)
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ func (u *userInterface) loop(g GraphicsContext) error {
|
||||
|
||||
// swapBuffers must be called from the main thread.
|
||||
func (u *userInterface) swapBuffers() {
|
||||
if graphicscommand.Driver().IsGL() {
|
||||
if drivers.Graphics().IsGL() {
|
||||
u.window.SwapBuffers()
|
||||
}
|
||||
}
|
||||
@ -932,7 +932,7 @@ func (u *userInterface) forceSetScreenSize(width, height int, scale float64, ful
|
||||
u.window.SetTitle(u.title)
|
||||
}
|
||||
|
||||
if graphicscommand.Driver().IsGL() {
|
||||
if drivers.Graphics().IsGL() {
|
||||
// SwapInterval is affected by the current monitor of the window.
|
||||
// This needs to be called at least after SetMonitor.
|
||||
// Without SwapInterval after SetMonitor, vsynch doesn't work (#375).
|
||||
@ -946,7 +946,7 @@ func (u *userInterface) forceSetScreenSize(width, height int, scale float64, ful
|
||||
glfw.SwapInterval(0)
|
||||
}
|
||||
}
|
||||
graphicscommand.Driver().SetVsyncEnabled(vsync)
|
||||
drivers.Graphics().SetVsyncEnabled(vsync)
|
||||
|
||||
u.toChangeSize = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user