func (q *commandQueue) Flush() {
	if q.err != nil {
		return
	}

	es := q.indices
	vs := q.vertices
	if recordLog() {
		fmt.Println("--")
	}

	theGraphicsDriver.Begin()
	for len(q.commands) > 0 {
		nv := 0
		ne := 0
		nc := 0
		for _, c := range q.commands {
			if c.NumIndices() > graphics.IndicesNum {
				panic(fmt.Sprintf("graphicscommand: c.NumIndices() must be <= graphics.IndicesNum but not at Flush: c.NumIndices(): %d, graphics.IndicesNum: %d", c.NumIndices(), graphics.IndicesNum))
			}
			if ne+c.NumIndices() > graphics.IndicesNum {
				break
			}
			nv += c.NumVertices()
			ne += c.NumIndices()
			nc++
		}
		if 0 < ne {
			theGraphicsDriver.SetVertices(vs[:nv], es[:ne])
			es = es[ne:]
			vs = vs[nv:]
		}
		indexOffset := 0
		for _, c := range q.commands[:nc] {
			if err := c.Exec(indexOffset); err != nil {
				q.err = err
				return
			}
			if recordLog() {
				fmt.Printf("%s\n", c)
			}
			// TODO: indexOffset should be reset if the command type is different
			// from the previous one. This fix is needed when another drawing command is
			// introduced than drawTrianglesCommand.
			indexOffset += c.NumIndices()
		}
		if 0 < nc {
			// Call glFlush to prevent black flicking (especially on Android (#226) and iOS).
			theGraphicsDriver.Flush()
		}
		q.commands = q.commands[nc:]
	}
	theGraphicsDriver.End()
	q.commands = nil
	q.nvertices = 0
	q.nindices = 0
	q.tmpNumIndices = 0
	q.nextIndex = 0
}
func (q *commandQueue) Flush() {
	if q.err != nil {
		return
	}

	es := q.indices
	vs := q.vertices
	if recordLog() {
		fmt.Println("--")
	}

	theGraphicsDriver.Begin()
	for len(q.commands) > 0 {
		nv := 0
		ne := 0
		nc := 0
		for _, c := range q.commands {
			if c.NumIndices() > graphics.IndicesNum {
				panic(fmt.Sprintf("graphicscommand: c.NumIndices() must be <= graphics.IndicesNum but not at Flush: c.NumIndices(): %d, graphics.IndicesNum: %d", c.NumIndices(), graphics.IndicesNum))
			}
			if ne+c.NumIndices() > graphics.IndicesNum {
				break
			}
			nv += c.NumVertices()
			ne += c.NumIndices()
			nc++
		}
		if 0 < ne {
			theGraphicsDriver.SetVertices(vs[:nv], es[:ne])
			es = es[ne:]
			vs = vs[nv:]
		}
		indexOffset := 0
		for _, c := range q.commands[:nc] {
			if err := c.Exec(indexOffset); err != nil {
				q.err = err
				return
			}
			if recordLog() {
				fmt.Printf("%s\n", c)
			}
			
			
			
			indexOffset += c.NumIndices()
		}
		if 0 < nc {
			
			theGraphicsDriver.Flush()
		}
		q.commands = q.commands[nc:]
	}
	theGraphicsDriver.End()
	q.commands = nil
	q.nvertices = 0
	q.nindices = 0
	q.tmpNumIndices = 0
	q.nextIndex = 0
}
func ( q * commandQueue ) Flush ( ) { if q . err != nil { return } es := q . indices vs := q . vertices if recordLog ( ) { fmt . Println ( " " ) } theGraphicsDriver . Begin ( ) for len ( q . commands ) > 0 { nv := 0 ne := 0 nc := 0 for _ , c := range q . commands { if c . NumIndices ( ) > graphics . IndicesNum { panic ( fmt . Sprintf ( " " , c . NumIndices ( ) , graphics . IndicesNum ) ) } if ne + c . NumIndices ( ) > graphics . IndicesNum { break } nv += c . NumVertices ( ) ne += c . NumIndices ( ) nc ++ } if 0 < ne { theGraphicsDriver . SetVertices ( vs [ : nv ] , es [ : ne ] ) es = es [ ne : ] vs = vs [ nv : ] } indexOffset := 0 for _ , c := range q . commands [ : nc ] { if err := c . Exec ( indexOffset ) ; err != nil { q . err = err return } if recordLog ( ) { fmt . Printf ( " \n " , c ) } // TODO: indexOffset should be reset if the command type is different // from the previous one. This fix is needed when another drawing command is // introduced than drawTrianglesCommand. indexOffset += c . NumIndices ( ) } if 0 < nc { // Call glFlush to prevent black flicking (especially on Android (#226) and iOS). theGraphicsDriver . Flush ( ) } q . commands = q . commands [ nc : ] } theGraphicsDriver . End ( ) q . commands = nil q . nvertices = 0 q . nindices = 0 q . tmpNumIndices = 0 q . nextIndex = 0 }
// Flush flushes the command queue.
Flush flushes the command queue .