mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
ebiten: bug fix: Set after Set resulted in a wrong color
Updates #2154 Updates #2176
This commit is contained in:
parent
66bf40dc84
commit
80c26e6dcc
2
image.go
2
image.go
@ -127,7 +127,7 @@ func (i *Image) resolveSetVerticesCacheIfNeeded() {
|
||||
i.setVerticesCache = nil
|
||||
|
||||
srcs := [graphics.ShaderImageNum]*ui.Image{emptyImage.image}
|
||||
i.image.DrawTriangles(srcs, vs, is, affine.ColorMIdentity{}, graphicsdriver.CompositeModeSourceOver, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, i.adjustedRegion(), graphicsdriver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false, true)
|
||||
i.image.DrawTriangles(srcs, vs, is, affine.ColorMIdentity{}, graphicsdriver.CompositeModeCopy, graphicsdriver.FilterNearest, graphicsdriver.AddressUnsafe, i.adjustedRegion(), graphicsdriver.Region{}, [graphics.ShaderImageNum - 1][2]float32{}, nil, nil, false, true)
|
||||
}
|
||||
|
||||
// Size returns the size of the image.
|
||||
|
@ -3350,3 +3350,29 @@ func TestImageTooManyDrawTriangles(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageSetOverSet(t *testing.T) {
|
||||
img := ebiten.NewImage(1, 1)
|
||||
img.Set(0, 0, color.RGBA{0xff, 0xff, 0xff, 0xff})
|
||||
if got, want := img.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
|
||||
// Apply the change by 'Set' by calling DrawImage.
|
||||
dummy := ebiten.NewImage(1, 1)
|
||||
img.DrawImage(dummy, nil)
|
||||
if got, want := img.At(0, 0), (color.RGBA{0xff, 0xff, 0xff, 0xff}); got != want {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
|
||||
img.Set(0, 0, color.RGBA{0x80, 0x80, 0x80, 0x80})
|
||||
if got, want := img.At(0, 0), (color.RGBA{0x80, 0x80, 0x80, 0x80}); got != want {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
|
||||
// Apply the change by 'Set' again.
|
||||
img.DrawImage(dummy, nil)
|
||||
if got, want := img.At(0, 0), (color.RGBA{0x80, 0x80, 0x80, 0x80}); got != want {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user