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

View File

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

View File

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

View File

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

View File

@ -307,14 +307,14 @@ func (c *uiContext) draw() {
op := &DrawImageOptions{}
s := c.screenScale()
switch vd := uiDriver().Graphics().VDirection(); vd {
case driver.VDownward:
switch vd := uiDriver().Graphics().FramebufferYDirection(); vd {
case driver.Upward:
// c.screen is special: its Y axis is down to up,
// and the origin point is lower left.
op.GeoM.Scale(s, -s)
_, h := c.offscreen.Size()
op.GeoM.Translate(0, float64(h)*s)
case driver.VUpward:
case driver.Downward:
op.GeoM.Scale(s, s)
default:
panic(fmt.Sprintf("ebiten: invalid v-direction: %d", vd))