mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Bug fix: Flush after filling (#419)
This commit is contained in:
parent
bb6dfeefd4
commit
12c24215b1
@ -490,7 +490,7 @@ func TestImageFill(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue 317
|
||||
// Issue #317
|
||||
func TestImageEdge(t *testing.T) {
|
||||
const (
|
||||
img0Width = 16
|
||||
@ -561,6 +561,28 @@ func TestImageEdge(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Issue #419
|
||||
func TestImageTooManyFill(t *testing.T) {
|
||||
const width = 256
|
||||
|
||||
src, _ := NewImage(1, 1, FilterNearest)
|
||||
dst, _ := NewImage(width, 1, FilterNearest)
|
||||
for i := 0; i < width; i++ {
|
||||
src.Fill(color.RGBA{uint8(i), uint8(i), uint8(i), 0xff})
|
||||
op := &DrawImageOptions{}
|
||||
op.GeoM.Translate(float64(i), 0)
|
||||
dst.DrawImage(src, op)
|
||||
}
|
||||
|
||||
for i := 0; i < width; i++ {
|
||||
got := color.RGBAModel.Convert(dst.At(i, 0))
|
||||
want := color.RGBA{uint8(i), uint8(i), uint8(i), 0xff}
|
||||
if got != want {
|
||||
t.Errorf("src At(%d, %d): got %#v, want: %#v", i, 0, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkDrawImage(b *testing.B) {
|
||||
img0, _ := NewImage(16, 16, FilterNearest)
|
||||
img1, _ := NewImage(16, 16, FilterNearest)
|
||||
|
@ -181,7 +181,13 @@ func (c *fillCommand) Exec(indexOffsetInBytes int) error {
|
||||
g := float64(cg) / max
|
||||
b := float64(cb) / max
|
||||
a := float64(ca) / max
|
||||
return opengl.GetContext().FillFramebuffer(r, g, b, a)
|
||||
if err := opengl.GetContext().FillFramebuffer(r, g, b, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Flush is needed after filling (#419)
|
||||
opengl.GetContext().Flush()
|
||||
return nil
|
||||
}
|
||||
|
||||
type drawImageCommand struct {
|
||||
|
Loading…
Reference in New Issue
Block a user