driver: Use framebuffer's Y directions

This commit is contained in:
Hajime Hoshi 2020-05-08 16:49:19 +09:00
parent c43ba6e17d
commit 8029dc352a
5 changed files with 13 additions and 13 deletions

View File

@ -32,7 +32,7 @@ type Graphics interface {
Reset() error Reset() error
Draw(indexLen int, indexOffset int, mode CompositeMode, colorM *affine.ColorM, filter Filter, address Address) error Draw(indexLen int, indexOffset int, mode CompositeMode, colorM *affine.ColorM, filter Filter, address Address) error
SetVsyncEnabled(enabled bool) SetVsyncEnabled(enabled bool)
VDirection() VDirection FramebufferYDirection() YDirection
NeedsRestoring() bool NeedsRestoring() bool
IsGL() bool IsGL() bool
HasHighPrecisionFloat() bool HasHighPrecisionFloat() bool
@ -59,9 +59,9 @@ type ReplacePixelsArgs struct {
Height int Height int
} }
type VDirection int type YDirection int
const ( const (
VUpward VDirection = iota Upward YDirection = iota
VDownward Downward
) )

View File

@ -684,8 +684,8 @@ func (g *Graphics) SetVsyncEnabled(enabled bool) {
g.view.setDisplaySyncEnabled(enabled) g.view.setDisplaySyncEnabled(enabled)
} }
func (g *Graphics) VDirection() driver.VDirection { func (g *Graphics) FramebufferYDirection() driver.YDirection {
return driver.VUpward return driver.Downward
} }
func (g *Graphics) NeedsRestoring() bool { func (g *Graphics) NeedsRestoring() bool {

View File

@ -91,8 +91,8 @@ func (g *Graphics) SetVsyncEnabled(enabled bool) {
panic("monogame: SetVsyncEnabled is not implemented yet") panic("monogame: SetVsyncEnabled is not implemented yet")
} }
func (g *Graphics) VDirection() driver.VDirection { func (g *Graphics) FramebufferYDirection() driver.YDirection {
return driver.VUpward return driver.Downward
} }
func (g *Graphics) NeedsRestoring() bool { func (g *Graphics) NeedsRestoring() bool {

View File

@ -129,8 +129,8 @@ func (g *Graphics) SetVsyncEnabled(enabled bool) {
// Do nothing // Do nothing
} }
func (g *Graphics) VDirection() driver.VDirection { func (g *Graphics) FramebufferYDirection() driver.YDirection {
return driver.VDownward return driver.Upward
} }
func (g *Graphics) NeedsRestoring() bool { func (g *Graphics) NeedsRestoring() bool {

View File

@ -307,14 +307,14 @@ func (c *uiContext) draw() {
op := &DrawImageOptions{} op := &DrawImageOptions{}
s := c.screenScale() s := c.screenScale()
switch vd := uiDriver().Graphics().VDirection(); vd { switch vd := uiDriver().Graphics().FramebufferYDirection(); vd {
case driver.VDownward: case driver.Upward:
// 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(s, -s) op.GeoM.Scale(s, -s)
_, h := c.offscreen.Size() _, h := c.offscreen.Size()
op.GeoM.Translate(0, float64(h)*s) op.GeoM.Translate(0, float64(h)*s)
case driver.VUpward: case driver.Downward:
op.GeoM.Scale(s, s) op.GeoM.Scale(s, s)
default: default:
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd)) panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd))