mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
internal/graphicsdriver: remove FramebufferYDirection
This commit is contained in:
parent
2dfdd80dc8
commit
08e6f5af86
@ -1149,10 +1149,6 @@ func (g *Graphics) SetVsyncEnabled(enabled bool) {
|
||||
func (g *Graphics) SetFullscreen(fullscreen bool) {
|
||||
}
|
||||
|
||||
func (g *Graphics) FramebufferYDirection() graphicsdriver.YDirection {
|
||||
return graphicsdriver.Downward
|
||||
}
|
||||
|
||||
func (g *Graphics) NeedsRestoring() bool {
|
||||
return false
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ type Graphics interface {
|
||||
NewScreenFramebufferImage(width, height int) (Image, error)
|
||||
SetVsyncEnabled(enabled bool)
|
||||
SetFullscreen(fullscreen bool)
|
||||
FramebufferYDirection() YDirection
|
||||
NeedsRestoring() bool
|
||||
NeedsClearingScreen() bool
|
||||
IsGL() bool
|
||||
@ -77,13 +76,6 @@ type WritePixelsArgs struct {
|
||||
Height int
|
||||
}
|
||||
|
||||
type YDirection int
|
||||
|
||||
const (
|
||||
Upward YDirection = iota
|
||||
Downward
|
||||
)
|
||||
|
||||
type Shader interface {
|
||||
ID() ShaderID
|
||||
Dispose()
|
||||
|
@ -610,10 +610,6 @@ func (g *Graphics) SetFullscreen(fullscreen bool) {
|
||||
g.view.setFullscreen(fullscreen)
|
||||
}
|
||||
|
||||
func (g *Graphics) FramebufferYDirection() graphicsdriver.YDirection {
|
||||
return graphicsdriver.Downward
|
||||
}
|
||||
|
||||
func (g *Graphics) NeedsRestoring() bool {
|
||||
return false
|
||||
}
|
||||
|
@ -275,11 +275,20 @@ func (g *Graphics) DrawTriangles(dstID graphicsdriver.ImageID, srcIDs [graphics.
|
||||
{
|
||||
const idx = graphics.ProjectionMatrixUniformVariableIndex
|
||||
g.uniformVars[idx].name = g.uniformVariableName(idx)
|
||||
g.uniformVars[idx].value = []float32{
|
||||
2 / float32(dw), 0, 0, 0,
|
||||
0, 2 / float32(dh), 0, 0,
|
||||
0, 0, 1, 0,
|
||||
-1, -1, 0, 1,
|
||||
if destination.screen {
|
||||
g.uniformVars[idx].value = []float32{
|
||||
2 / float32(dw), 0, 0, 0,
|
||||
0, -2 / float32(dh), 0, 0,
|
||||
0, 0, 1, 0,
|
||||
-1, 1, 0, 1,
|
||||
}
|
||||
} else {
|
||||
g.uniformVars[idx].value = []float32{
|
||||
2 / float32(dw), 0, 0, 0,
|
||||
0, 2 / float32(dh), 0, 0,
|
||||
0, 0, 1, 0,
|
||||
-1, -1, 0, 1,
|
||||
}
|
||||
}
|
||||
g.uniformVars[idx].typ = shader.ir.Uniforms[idx]
|
||||
}
|
||||
@ -334,10 +343,6 @@ func (g *Graphics) SetFullscreen(fullscreen bool) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
func (g *Graphics) FramebufferYDirection() graphicsdriver.YDirection {
|
||||
return graphicsdriver.Upward
|
||||
}
|
||||
|
||||
func (g *Graphics) NeedsRestoring() bool {
|
||||
return g.context.needsRestoring()
|
||||
}
|
||||
|
@ -218,35 +218,15 @@ func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics) {
|
||||
c.screen.clear()
|
||||
}
|
||||
|
||||
ga := 1.0
|
||||
gd := 1.0
|
||||
gtx := 0.0
|
||||
gty := 0.0
|
||||
|
||||
screenScale, offsetX, offsetY := c.screenScaleAndOffsets()
|
||||
s := screenScale
|
||||
switch y := graphicsDriver.FramebufferYDirection(); y {
|
||||
case graphicsdriver.Upward:
|
||||
ga *= s
|
||||
gd *= -s
|
||||
gty += float64(c.offscreen.height) * s
|
||||
case graphicsdriver.Downward:
|
||||
ga *= s
|
||||
gd *= s
|
||||
default:
|
||||
panic(fmt.Sprintf("ui: invalid y-direction: %d", y))
|
||||
}
|
||||
|
||||
gtx += offsetX
|
||||
gty += offsetY
|
||||
|
||||
var shader *Shader
|
||||
switch {
|
||||
case !theGlobalState.isScreenFilterEnabled():
|
||||
shader = NearestFilterShader
|
||||
case math.Floor(s) == s:
|
||||
case math.Floor(screenScale) == screenScale:
|
||||
shader = NearestFilterShader
|
||||
case s > 1:
|
||||
case screenScale > 1:
|
||||
shader = screenShader
|
||||
default:
|
||||
// screenShader works with >=1 scale, but does not well with <1 scale.
|
||||
@ -269,7 +249,7 @@ func (c *context) drawGame(graphicsDriver graphicsdriver.Graphics) {
|
||||
|
||||
vs := graphics.QuadVertices(
|
||||
0, 0, float32(c.offscreen.width), float32(c.offscreen.height),
|
||||
float32(ga), 0, 0, float32(gd), float32(gtx), float32(gty),
|
||||
float32(screenScale), 0, 0, float32(screenScale), float32(offsetX), float32(offsetY),
|
||||
1, 1, 1, 1)
|
||||
is := graphics.QuadIndices()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user