mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
graphics: Use the common vertices backend for PutVertex
This commit is contained in:
parent
008de78cec
commit
3eee4754c5
2
image.go
2
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 {
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user