diff --git a/graphics_mac.go b/graphics_mac.go index fa1f11e20..6138b8ec0 100644 --- a/graphics_mac.go +++ b/graphics_mac.go @@ -29,7 +29,7 @@ package ebiten import "C" import ( - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl" @@ -52,7 +52,7 @@ func init() { } } -func graphicsDriver() graphicsdriver.GraphicsDriver { +func graphicsDriver() driver.Graphics { if isMetalSupported { return metal.Get() } diff --git a/graphics_notmac.go b/graphics_notmac.go index 136d52413..4baa78efe 100644 --- a/graphics_notmac.go +++ b/graphics_notmac.go @@ -17,10 +17,10 @@ package ebiten import ( - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl" ) -func graphicsDriver() graphicsdriver.GraphicsDriver { +func graphicsDriver() driver.Graphics { return opengl.Get() } diff --git a/graphicscontext.go b/graphicscontext.go index 22c26ba5b..2aff1c724 100644 --- a/graphicscontext.go +++ b/graphicscontext.go @@ -19,8 +19,8 @@ import ( "math" "github.com/hajimehoshi/ebiten/internal/clock" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphicscommand" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/internal/hooks" "github.com/hajimehoshi/ebiten/internal/shareable" "github.com/hajimehoshi/ebiten/internal/ui" @@ -128,12 +128,12 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error { op := &DrawImageOptions{} switch vd := graphicsDriver().VDirection(); vd { - case graphicsdriver.VDownward: + case driver.VDownward: // c.screen is special: its Y axis is down to up, // and the origin point is lower left. op.GeoM.Scale(c.screenScale, -c.screenScale) op.GeoM.Translate(0, float64(c.screenHeight)) - case graphicsdriver.VUpward: + case driver.VUpward: op.GeoM.Scale(c.screenScale, c.screenScale) default: panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd)) diff --git a/internal/graphicsdriver/graphicsdriver.go b/internal/driver/graphics.go similarity index 96% rename from internal/graphicsdriver/graphicsdriver.go rename to internal/driver/graphics.go index 987074239..92e2b6d96 100644 --- a/internal/graphicsdriver/graphicsdriver.go +++ b/internal/driver/graphics.go @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package graphicsdriver +package driver import ( "github.com/hajimehoshi/ebiten/internal/affine" "github.com/hajimehoshi/ebiten/internal/graphics" ) -type GraphicsDriver interface { +type Graphics interface { SetWindow(window uintptr) SetVertices(vertices []float32, indices []uint16) Flush() diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 93187d3b5..02bd1b560 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -18,13 +18,13 @@ import ( "fmt" "github.com/hajimehoshi/ebiten/internal/affine" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" ) -var theGraphicsDriver graphicsdriver.GraphicsDriver +var theGraphicsDriver driver.Graphics -func SetGraphicsDriver(driver graphicsdriver.GraphicsDriver) { +func SetGraphicsDriver(driver driver.Graphics) { theGraphicsDriver = driver } diff --git a/internal/graphicscommand/image.go b/internal/graphicscommand/image.go index 92ed1b34a..3a3630498 100644 --- a/internal/graphicscommand/image.go +++ b/internal/graphicscommand/image.go @@ -16,8 +16,8 @@ package graphicscommand import ( "github.com/hajimehoshi/ebiten/internal/affine" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" ) type lastCommand int @@ -31,7 +31,7 @@ const ( // Image represents an image that is implemented with OpenGL. type Image struct { - image graphicsdriver.Image + image driver.Image width int height int screen bool diff --git a/internal/graphicsdriver/metal/driver.go b/internal/graphicsdriver/metal/driver.go index 5b6a21cb1..3e1792b5c 100644 --- a/internal/graphicsdriver/metal/driver.go +++ b/internal/graphicsdriver/metal/driver.go @@ -22,8 +22,8 @@ import ( "unsafe" "github.com/hajimehoshi/ebiten/internal/affine" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ca" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns" @@ -392,7 +392,7 @@ func (d *Driver) checkSize(width, height int) { } } -func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) { +func (d *Driver) NewImage(width, height int) (driver.Image, error) { d.checkSize(width, height) td := mtl.TextureDescriptor{ PixelFormat: mtl.PixelFormatRGBA8UNorm, @@ -417,7 +417,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) { }, nil } -func (d *Driver) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) { +func (d *Driver) NewScreenFramebufferImage(width, height int) (driver.Image, error) { mainthread.Run(func() error { d.ml.SetDrawableSize(width, height) return nil @@ -672,8 +672,8 @@ func (d *Driver) SetVsyncEnabled(enabled bool) { d.ml.SetDisplaySyncEnabled(enabled) } -func (d *Driver) VDirection() graphicsdriver.VDirection { - return graphicsdriver.VUpward +func (d *Driver) VDirection() driver.VDirection { + return driver.VUpward } func (d *Driver) IsGL() bool { diff --git a/internal/graphicsdriver/opengl/driver.go b/internal/graphicsdriver/opengl/driver.go index 25ddaf506..c2724ae49 100644 --- a/internal/graphicsdriver/opengl/driver.go +++ b/internal/graphicsdriver/opengl/driver.go @@ -18,8 +18,8 @@ import ( "fmt" "github.com/hajimehoshi/ebiten/internal/affine" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphics" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" ) var theDriver Driver @@ -53,7 +53,7 @@ func (d *Driver) checkSize(width, height int) { } } -func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) { +func (d *Driver) NewImage(width, height int) (driver.Image, error) { i := &Image{ driver: d, width: width, @@ -70,7 +70,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) { return i, nil } -func (d *Driver) NewScreenFramebufferImage(width, height int) (graphicsdriver.Image, error) { +func (d *Driver) NewScreenFramebufferImage(width, height int) (driver.Image, error) { d.checkSize(width, height) i := &Image{ driver: d, @@ -114,8 +114,8 @@ func (d *Driver) SetVsyncEnabled(enabled bool) { // Do nothing } -func (d *Driver) VDirection() graphicsdriver.VDirection { - return graphicsdriver.VDownward +func (d *Driver) VDirection() driver.VDirection { + return driver.VDownward } func (d *Driver) IsGL() bool { diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index fccfb3305..f31e9fb5e 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -27,8 +27,8 @@ import ( "time" "github.com/hajimehoshi/ebiten/internal/devicescale" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/glfw" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" "github.com/hajimehoshi/ebiten/internal/hooks" "github.com/hajimehoshi/ebiten/internal/input" "github.com/hajimehoshi/ebiten/internal/mainthread" @@ -65,7 +65,7 @@ type userInterface struct { reqWidth int reqHeight int - driver graphicsdriver.GraphicsDriver + driver driver.Graphics m sync.Mutex } @@ -577,7 +577,7 @@ func DeviceScaleFactor() float64 { return f } -func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver graphicsdriver.GraphicsDriver) error { +func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver driver.Graphics) error { u := currentUI _ = mainthread.Run(func() error { u.driver = driver diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index 2faf67cea..7ac665189 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -25,7 +25,7 @@ import ( "github.com/gopherjs/gopherwasm/js" "github.com/hajimehoshi/ebiten/internal/devicescale" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/hooks" "github.com/hajimehoshi/ebiten/internal/input" ) @@ -373,7 +373,7 @@ func Loop(ch <-chan error) error { return <-ch } -func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver graphicsdriver.GraphicsDriver) error { +func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver driver.Graphics) error { u := currentUI document.Set("title", title) u.setScreenSize(width, height, scale, u.fullscreen) diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index 3d720b038..e384fa2dd 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -31,7 +31,7 @@ import ( "golang.org/x/mobile/gl" "github.com/hajimehoshi/ebiten/internal/devicescale" - "github.com/hajimehoshi/ebiten/internal/graphicsdriver" + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl" "github.com/hajimehoshi/ebiten/internal/hooks" "github.com/hajimehoshi/ebiten/internal/input" @@ -142,7 +142,7 @@ func appMain(a app.App) { } } -func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver graphicsdriver.GraphicsDriver) error { +func Run(width, height int, scale float64, title string, g GraphicsContext, mainloop bool, driver driver.Graphics) error { u := currentUI u.m.Lock()