mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 18:52:44 +01:00
graphicscommand: Bug fix: Use graphics.InternalImageSize before specifying the size
Fixes #887
This commit is contained in:
parent
26296993f8
commit
7e0dee0730
@ -154,7 +154,7 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []f
|
|||||||
}
|
}
|
||||||
|
|
||||||
n := len(vertices) / graphics.VertexFloatNum
|
n := len(vertices) / graphics.VertexFloatNum
|
||||||
q.appendVertices(vertices, float32(dst.width), float32(dst.height))
|
q.appendVertices(vertices, float32(graphics.InternalImageSize(dst.width)), float32(graphics.InternalImageSize(dst.height)))
|
||||||
q.appendIndices(indices, uint16(q.nextIndex))
|
q.appendIndices(indices, uint16(q.nextIndex))
|
||||||
q.nextIndex += n
|
q.nextIndex += n
|
||||||
q.tmpNumIndices += len(indices)
|
q.tmpNumIndices += len(indices)
|
||||||
|
@ -295,4 +295,39 @@ func TestReplacePixelsAfterDrawTriangles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #887
|
||||||
|
func TestSmallImages(t *testing.T) {
|
||||||
|
const w, h = 4, 8
|
||||||
|
src := NewImage(w, h)
|
||||||
|
defer src.Dispose()
|
||||||
|
dst := NewImage(w, h)
|
||||||
|
defer dst.Dispose()
|
||||||
|
|
||||||
|
pix := make([]byte, 4*w*h)
|
||||||
|
for i := 0; i < w*h; i++ {
|
||||||
|
pix[4*i] = 0xff
|
||||||
|
pix[4*i+1] = 0xff
|
||||||
|
pix[4*i+2] = 0xff
|
||||||
|
pix[4*i+3] = 0xff
|
||||||
|
}
|
||||||
|
src.ReplacePixels(pix)
|
||||||
|
|
||||||
|
vs := make([]float32, 4*graphics.VertexFloatNum)
|
||||||
|
graphics.PutQuadVertices(vs, src, 0, 0, w, h, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1)
|
||||||
|
is := graphics.QuadIndices()
|
||||||
|
dst.DrawTriangles(src, vs, is, nil, graphics.CompositeModeSourceOver, graphics.FilterNearest, graphics.AddressClampToZero)
|
||||||
|
|
||||||
|
for j := 0; j < h; j++ {
|
||||||
|
for i := 0; i < w; i++ {
|
||||||
|
r, _, _, a := dst.At(i, j)
|
||||||
|
if got, want := r, byte(0xff); got != want {
|
||||||
|
t.Errorf("At(%d, %d) red: got: %d, want: %d", i, j, got, want)
|
||||||
|
}
|
||||||
|
if got, want := a, byte(0xff); got != want {
|
||||||
|
t.Errorf("At(%d, %d) alpha: got: %d, want: %d", i, j, got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add tests to extend shareable image out of the main loop
|
// TODO: Add tests to extend shareable image out of the main loop
|
||||||
|
Loading…
Reference in New Issue
Block a user