mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
mipmap: Bug fix: Wrong level calculation when the indices are empty
Fixes #1269
This commit is contained in:
parent
a43efb66b2
commit
da98e67345
@ -2227,3 +2227,14 @@ func TestImageCompositeModeMultiply(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #1269
|
||||
func TestImageEmptyTriangle(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
dst, _ := NewImage(w, h, FilterDefault)
|
||||
src, _ := NewImage(1, 1, FilterDefault)
|
||||
|
||||
vs := []Vertex{}
|
||||
is := []uint16{}
|
||||
dst.DrawTriangles(vs, is, src, nil)
|
||||
}
|
||||
|
@ -91,6 +91,10 @@ func (m *Mipmap) Pixels(x, y, width, height int) ([]byte, error) {
|
||||
}
|
||||
|
||||
func (m *Mipmap) DrawTriangles(srcs [graphics.ShaderImageNum]*Mipmap, vertices []float32, indices []uint16, colorm *affine.ColorM, mode driver.CompositeMode, filter driver.Filter, address driver.Address, sourceRegion driver.Region, shader *Shader, uniforms []interface{}, canSkipMipmap bool) {
|
||||
if len(indices) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
level := 0
|
||||
// TODO: Do we need to check all the sources' states of being volatile?
|
||||
if !canSkipMipmap && srcs[0] != nil && !srcs[0].volatile && filter != driver.FilterScreen {
|
||||
@ -119,6 +123,9 @@ func (m *Mipmap) DrawTriangles(srcs [graphics.ShaderImageNum]*Mipmap, vertices [
|
||||
level = l
|
||||
}
|
||||
}
|
||||
if level == math.MaxInt32 {
|
||||
panic("mipmap: level must be calculated at least once but not")
|
||||
}
|
||||
}
|
||||
|
||||
if colorm != nil && colorm.ScaleOnly() {
|
||||
|
Loading…
Reference in New Issue
Block a user