mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
graphics: Bug fix: Don't adjust texels on iOS Safari
This commit is contained in:
parent
d1333e92a5
commit
9399622127
@ -26,7 +26,7 @@ func IsBrowser() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isIOS() bool {
|
func IsIOSSafari() bool {
|
||||||
ua := js.Global.Get("navigator").Get("userAgent").String()
|
ua := js.Global.Get("navigator").Get("userAgent").String()
|
||||||
if !strings.Contains(ua, "iPhone") {
|
if !strings.Contains(ua, "iPhone") {
|
||||||
return false
|
return false
|
||||||
@ -46,5 +46,5 @@ func isAndroidChrome() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsMobileBrowser() bool {
|
func IsMobileBrowser() bool {
|
||||||
return isIOS() || isAndroidChrome()
|
return IsIOSSafari() || isAndroidChrome()
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,10 @@ func IsBrowser() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsIOSSafari() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func IsMobileBrowser() bool {
|
func IsMobileBrowser() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
16
vertices.go
16
vertices.go
@ -17,13 +17,21 @@ package ebiten
|
|||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal/affine"
|
"github.com/hajimehoshi/ebiten/internal/affine"
|
||||||
"github.com/hajimehoshi/ebiten/internal/restorable"
|
"github.com/hajimehoshi/ebiten/internal/restorable"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
// texelAdjustment represents a number to be used to adjust texel.
|
// texelAdjustment represents a number to be used to adjust texel.
|
||||||
// Texels are adjusted by amount propotional to inverse of texelAdjustment.
|
// Texels are adjusted by amount propotional to inverse of texelAdjustment.
|
||||||
// This is necessary not to use unexpected pixels outside of texels.
|
// This is necessary not to use unexpected pixels outside of texels.
|
||||||
// See #317.
|
// See #317.
|
||||||
const texelAdjustment = 256
|
var texelAdjustment float32 = 256
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if web.IsIOSSafari() {
|
||||||
|
// Texel adjustment causes glitches on iOS Safari.
|
||||||
|
texelAdjustment = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
quadFloat32Num = restorable.QuadVertexSizeInBytes() / 4
|
quadFloat32Num = restorable.QuadVertexSizeInBytes() / 4
|
||||||
@ -75,8 +83,10 @@ func vertices(sx0, sy0, sx1, sy1 int, width, height int, geo *affine.GeoM) []flo
|
|||||||
x0, y0, x1, y1 := float32(0), float32(0), float32(sx1-sx0), float32(sy1-sy0)
|
x0, y0, x1, y1 := float32(0), float32(0), float32(sx1-sx0), float32(sy1-sy0)
|
||||||
u0, v0, u1, v1 := float32(sx0)/wf, float32(sy0)/hf, float32(sx1)/wf, float32(sy1)/hf
|
u0, v0, u1, v1 := float32(sx0)/wf, float32(sy0)/hf, float32(sx1)/wf, float32(sy1)/hf
|
||||||
// Adjust texels to fix a problem that outside texels are used (#317).
|
// Adjust texels to fix a problem that outside texels are used (#317).
|
||||||
u1 -= 1.0 / wf / texelAdjustment
|
if texelAdjustment > 0 {
|
||||||
v1 -= 1.0 / hf / texelAdjustment
|
u1 -= 1.0 / wf / texelAdjustment
|
||||||
|
v1 -= 1.0 / hf / texelAdjustment
|
||||||
|
}
|
||||||
vs[0] = x0
|
vs[0] = x0
|
||||||
vs[1] = y0
|
vs[1] = y0
|
||||||
vs[2] = u0
|
vs[2] = u0
|
||||||
|
Loading…
Reference in New Issue
Block a user