graphics: Use the common vertices backend for PutVertex

This commit is contained in:
Hajime Hoshi 2019-06-21 02:30:58 +09:00
parent 008de78cec
commit 3eee4754c5
2 changed files with 6 additions and 7 deletions

View File

@ -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 {

View File

@ -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]