mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Move graphicsdriver.GrapahicsDriver to driver.Graphics
This commit is contained in:
parent
747d1be54e
commit
7445144194
@ -29,7 +29,7 @@ package ebiten
|
|||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
import (
|
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"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
||||||
@ -52,7 +52,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func graphicsDriver() graphicsdriver.GraphicsDriver {
|
func graphicsDriver() driver.Graphics {
|
||||||
if isMetalSupported {
|
if isMetalSupported {
|
||||||
return metal.Get()
|
return metal.Get()
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
package ebiten
|
package ebiten
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/opengl"
|
||||||
)
|
)
|
||||||
|
|
||||||
func graphicsDriver() graphicsdriver.GraphicsDriver {
|
func graphicsDriver() driver.Graphics {
|
||||||
return opengl.Get()
|
return opengl.Get()
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/clock"
|
"github.com/hajimehoshi/ebiten/internal/clock"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||||
"github.com/hajimehoshi/ebiten/internal/shareable"
|
"github.com/hajimehoshi/ebiten/internal/shareable"
|
||||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||||
@ -128,12 +128,12 @@ func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
|||||||
op := &DrawImageOptions{}
|
op := &DrawImageOptions{}
|
||||||
|
|
||||||
switch vd := graphicsDriver().VDirection(); vd {
|
switch vd := graphicsDriver().VDirection(); vd {
|
||||||
case graphicsdriver.VDownward:
|
case driver.VDownward:
|
||||||
// c.screen is special: its Y axis is down to up,
|
// c.screen is special: its Y axis is down to up,
|
||||||
// and the origin point is lower left.
|
// and the origin point is lower left.
|
||||||
op.GeoM.Scale(c.screenScale, -c.screenScale)
|
op.GeoM.Scale(c.screenScale, -c.screenScale)
|
||||||
op.GeoM.Translate(0, float64(c.screenHeight))
|
op.GeoM.Translate(0, float64(c.screenHeight))
|
||||||
case graphicsdriver.VUpward:
|
case driver.VUpward:
|
||||||
op.GeoM.Scale(c.screenScale, c.screenScale)
|
op.GeoM.Scale(c.screenScale, c.screenScale)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd))
|
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd))
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package graphicsdriver
|
package driver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GraphicsDriver interface {
|
type Graphics interface {
|
||||||
SetWindow(window uintptr)
|
SetWindow(window uintptr)
|
||||||
SetVertices(vertices []float32, indices []uint16)
|
SetVertices(vertices []float32, indices []uint16)
|
||||||
Flush()
|
Flush()
|
@ -18,13 +18,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"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
|
theGraphicsDriver = driver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ package graphicscommand
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type lastCommand int
|
type lastCommand int
|
||||||
@ -31,7 +31,7 @@ const (
|
|||||||
|
|
||||||
// Image represents an image that is implemented with OpenGL.
|
// Image represents an image that is implemented with OpenGL.
|
||||||
type Image struct {
|
type Image struct {
|
||||||
image graphicsdriver.Image
|
image driver.Image
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
screen bool
|
screen bool
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"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/ca"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/mtl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver/metal/ns"
|
"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)
|
d.checkSize(width, height)
|
||||||
td := mtl.TextureDescriptor{
|
td := mtl.TextureDescriptor{
|
||||||
PixelFormat: mtl.PixelFormatRGBA8UNorm,
|
PixelFormat: mtl.PixelFormatRGBA8UNorm,
|
||||||
@ -417,7 +417,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
|
|||||||
}, nil
|
}, 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 {
|
mainthread.Run(func() error {
|
||||||
d.ml.SetDrawableSize(width, height)
|
d.ml.SetDrawableSize(width, height)
|
||||||
return nil
|
return nil
|
||||||
@ -672,8 +672,8 @@ func (d *Driver) SetVsyncEnabled(enabled bool) {
|
|||||||
d.ml.SetDisplaySyncEnabled(enabled)
|
d.ml.SetDisplaySyncEnabled(enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) VDirection() graphicsdriver.VDirection {
|
func (d *Driver) VDirection() driver.VDirection {
|
||||||
return graphicsdriver.VUpward
|
return driver.VUpward
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) IsGL() bool {
|
func (d *Driver) IsGL() bool {
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var theDriver Driver
|
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{
|
i := &Image{
|
||||||
driver: d,
|
driver: d,
|
||||||
width: width,
|
width: width,
|
||||||
@ -70,7 +70,7 @@ func (d *Driver) NewImage(width, height int) (graphicsdriver.Image, error) {
|
|||||||
return i, nil
|
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)
|
d.checkSize(width, height)
|
||||||
i := &Image{
|
i := &Image{
|
||||||
driver: d,
|
driver: d,
|
||||||
@ -114,8 +114,8 @@ func (d *Driver) SetVsyncEnabled(enabled bool) {
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) VDirection() graphicsdriver.VDirection {
|
func (d *Driver) VDirection() driver.VDirection {
|
||||||
return graphicsdriver.VDownward
|
return driver.VDownward
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) IsGL() bool {
|
func (d *Driver) IsGL() bool {
|
||||||
|
@ -27,8 +27,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/glfw"
|
"github.com/hajimehoshi/ebiten/internal/glfw"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicsdriver"
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||||
"github.com/hajimehoshi/ebiten/internal/input"
|
"github.com/hajimehoshi/ebiten/internal/input"
|
||||||
"github.com/hajimehoshi/ebiten/internal/mainthread"
|
"github.com/hajimehoshi/ebiten/internal/mainthread"
|
||||||
@ -65,7 +65,7 @@ type userInterface struct {
|
|||||||
reqWidth int
|
reqWidth int
|
||||||
reqHeight int
|
reqHeight int
|
||||||
|
|
||||||
driver graphicsdriver.GraphicsDriver
|
driver driver.Graphics
|
||||||
|
|
||||||
m sync.Mutex
|
m sync.Mutex
|
||||||
}
|
}
|
||||||
@ -577,7 +577,7 @@ func DeviceScaleFactor() float64 {
|
|||||||
return f
|
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
|
u := currentUI
|
||||||
_ = mainthread.Run(func() error {
|
_ = mainthread.Run(func() error {
|
||||||
u.driver = driver
|
u.driver = driver
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/gopherjs/gopherwasm/js"
|
"github.com/gopherjs/gopherwasm/js"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
"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/hooks"
|
||||||
"github.com/hajimehoshi/ebiten/internal/input"
|
"github.com/hajimehoshi/ebiten/internal/input"
|
||||||
)
|
)
|
||||||
@ -373,7 +373,7 @@ func Loop(ch <-chan error) error {
|
|||||||
return <-ch
|
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
|
u := currentUI
|
||||||
document.Set("title", title)
|
document.Set("title", title)
|
||||||
u.setScreenSize(width, height, scale, u.fullscreen)
|
u.setScreenSize(width, height, scale, u.fullscreen)
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
"golang.org/x/mobile/gl"
|
"golang.org/x/mobile/gl"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/internal/devicescale"
|
"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/graphicsdriver/opengl"
|
||||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||||
"github.com/hajimehoshi/ebiten/internal/input"
|
"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 := currentUI
|
||||||
|
|
||||||
u.m.Lock()
|
u.m.Lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user