mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
parent
e829e650f2
commit
78ed824351
@ -14,6 +14,10 @@
|
|||||||
|
|
||||||
package graphics
|
package graphics
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
theVerticesBackend = &verticesBackend{}
|
theVerticesBackend = &verticesBackend{}
|
||||||
)
|
)
|
||||||
@ -21,6 +25,7 @@ var (
|
|||||||
type verticesBackend struct {
|
type verticesBackend struct {
|
||||||
backend []float32
|
backend []float32
|
||||||
head int
|
head int
|
||||||
|
m sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -34,6 +39,8 @@ func (v *verticesBackend) slice(n int) []float32 {
|
|||||||
panic("not reached")
|
panic("not reached")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
v.m.Lock()
|
||||||
|
|
||||||
need := n * VertexFloatNum
|
need := n * VertexFloatNum
|
||||||
if v.head+need > len(v.backend) {
|
if v.head+need > len(v.backend) {
|
||||||
v.backend = nil
|
v.backend = nil
|
||||||
@ -46,6 +53,8 @@ func (v *verticesBackend) slice(n int) []float32 {
|
|||||||
|
|
||||||
s := v.backend[v.head : v.head+need]
|
s := v.backend[v.head : v.head+need]
|
||||||
v.head += need
|
v.head += need
|
||||||
|
|
||||||
|
v.m.Unlock()
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user