graphics: Calc capacity of vertices

This commit is contained in:
Hajime Hoshi 2016-10-27 01:42:18 +09:00
parent fb4ac5cd56
commit fbf6b6c525

View File

@ -126,7 +126,14 @@ func (q *commandQueue) Flush(context *opengl.Context) error {
// glViewport must be called at least at every frame on iOS.
context.ResetViewportSize()
for _, g := range q.commandGroups() {
vertices := []int16{}
n := 0
for _, c := range g {
switch c := c.(type) {
case *drawImageCommand:
n += len(c.vertices)
}
}
vertices := make([]int16, 0, n)
for _, c := range g {
switch c := c.(type) {
case *drawImageCommand: