diff --git a/image.go b/image.go index eaa95d806..88e9b3e73 100644 --- a/image.go +++ b/image.go @@ -481,7 +481,7 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o filter = graphics.Filter(img.filter) } - vs := make([]float32, len(vertices)*graphics.VertexFloatNum) + vs := graphics.VertexSlice(len(vertices)) src := img.mipmap.original() r := img.Bounds() for idx, v := range vertices { diff --git a/internal/graphics/vertices.go b/internal/graphics/vertices.go index bcf22cb5a..de0caef2f 100644 --- a/internal/graphics/vertices.go +++ b/internal/graphics/vertices.go @@ -35,11 +35,6 @@ const ( ) func (v *verticesBackend) slice(n int) []float32 { - const num = 1024 - if n > num { - panic(fmt.Sprintf("graphics: n must be <= num but not: n: %d, num: %d", n, num)) - } - v.m.Lock() need := n * VertexFloatNum @@ -49,7 +44,11 @@ func (v *verticesBackend) slice(n int) []float32 { } if v.backend == nil { - v.backend = make([]float32, VertexFloatNum*num) + l := 1024 + if n > l { + l = n + } + v.backend = make([]float32, VertexFloatNum*l) } s := v.backend[v.head : v.head+need]