mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
graphics: Bug fix: render source might not be initialized
This commit is contained in:
parent
3f75da5f35
commit
e537cb2c27
@ -1095,3 +1095,33 @@ func TestImageSubImageSize(t *testing.T) {
|
||||
t.Errorf("got: %v, want: %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageDrawImmediately(t *testing.T) {
|
||||
const w, h = 16, 16
|
||||
img0, _ := NewImage(w, h, FilterDefault)
|
||||
img1, _ := NewImage(w, h, FilterDefault)
|
||||
// Do not manipulate img0 here.
|
||||
|
||||
img0.Fill(color.RGBA{0xff, 0, 0, 0xff})
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
got := img0.At(i, j).(color.RGBA)
|
||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
||||
if got != want {
|
||||
t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
img0.DrawImage(img1, nil)
|
||||
|
||||
for j := 0; j < h; j++ {
|
||||
for i := 0; i < w; i++ {
|
||||
got := img0.At(i, j).(color.RGBA)
|
||||
want := color.RGBA{0xff, 0, 0, 0xff}
|
||||
if got != want {
|
||||
t.Errorf("img0.At(%d, %d): got %v, want: %v", i, j, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +143,21 @@ func (i *Image) DrawImage(src *Image, vertices []float32, indices []uint16, clr
|
||||
default:
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
switch src.state {
|
||||
case imageStateInit:
|
||||
src.clearByReplacingPixels()
|
||||
case imageStateReplacePixelsOnly:
|
||||
// Do nothing
|
||||
// TODO: Check the region.
|
||||
case imageStateDrawable:
|
||||
// Do nothing
|
||||
case imageStateScreen:
|
||||
panic("not reached")
|
||||
default:
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
theCommandQueue.EnqueueDrawImageCommand(i, src, vertices, indices, clr, mode, filter)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user