mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-03 22:44:28 +01:00
mipmap: Bug fix: Use more negative mipmaps when float precision is low
Fixes #1044
This commit is contained in:
parent
c99fd1a742
commit
4c8137ccf5
@ -26,6 +26,12 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/shareable"
|
"github.com/hajimehoshi/ebiten/internal/shareable"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var graphicsDriver driver.Graphics
|
||||||
|
|
||||||
|
func SetGraphicsDriver(graphics driver.Graphics) {
|
||||||
|
graphicsDriver = graphics
|
||||||
|
}
|
||||||
|
|
||||||
func BeginFrame() error {
|
func BeginFrame() error {
|
||||||
return shareable.BeginFrame()
|
return shareable.BeginFrame()
|
||||||
}
|
}
|
||||||
@ -126,8 +132,9 @@ func (m *Mipmap) DrawImage(src *Mipmap, bounds image.Rectangle, geom *GeoM, colo
|
|||||||
if level > 6 {
|
if level > 6 {
|
||||||
level = 6
|
level = 6
|
||||||
}
|
}
|
||||||
if level < -6 {
|
// If tooBigScale is 4, level -10 means that the maximum scale is 4 * 2^10 = 4096. This should be enough.
|
||||||
level = -6
|
if level < -10 {
|
||||||
|
level = -10
|
||||||
}
|
}
|
||||||
|
|
||||||
cr, cg, cb, ca := float32(1), float32(1), float32(1), float32(1)
|
cr, cg, cb, ca := float32(1), float32(1), float32(1), float32(1)
|
||||||
@ -293,7 +300,10 @@ func (m *Mipmap) mipmapLevel(geom *GeoM, width, height int, filter driver.Filter
|
|||||||
|
|
||||||
// Use 'negative' mipmap to render edges correctly (#611, #907).
|
// Use 'negative' mipmap to render edges correctly (#611, #907).
|
||||||
// It looks like 128 is the enlargement factor that causes edge missings to pass the test TestImageStretch.
|
// It looks like 128 is the enlargement factor that causes edge missings to pass the test TestImageStretch.
|
||||||
const tooBigScale = 128
|
var tooBigScale float32 = 128
|
||||||
|
if !graphicsDriver.HasHighPrecisionFloat() {
|
||||||
|
tooBigScale = 4
|
||||||
|
}
|
||||||
if sx, sy := geomScaleSize(geom); sx >= tooBigScale || sy >= tooBigScale {
|
if sx, sy := geomScaleSize(geom); sx >= tooBigScale || sy >= tooBigScale {
|
||||||
// If the filter is not nearest, the target needs to be rendered with graduation. Don't use mipmaps.
|
// If the filter is not nearest, the target needs to be rendered with graduation. Don't use mipmaps.
|
||||||
if filter != driver.FilterNearest {
|
if filter != driver.FilterNearest {
|
||||||
|
@ -24,10 +24,12 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
|
||||||
"github.com/hajimehoshi/ebiten/internal/hooks"
|
"github.com/hajimehoshi/ebiten/internal/hooks"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/mipmap"
|
||||||
"github.com/hajimehoshi/ebiten/internal/shareable"
|
"github.com/hajimehoshi/ebiten/internal/shareable"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
mipmap.SetGraphicsDriver(uiDriver().Graphics())
|
||||||
shareable.SetGraphicsDriver(uiDriver().Graphics())
|
shareable.SetGraphicsDriver(uiDriver().Graphics())
|
||||||
graphicscommand.SetGraphicsDriver(uiDriver().Graphics())
|
graphicscommand.SetGraphicsDriver(uiDriver().Graphics())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user