graphicsutil: Remove dependency on graphicscommand

This commit is contained in:
Hajime Hoshi 2018-10-28 23:00:10 +09:00
parent 7767bcfdd8
commit 395b46d8da
2 changed files with 6 additions and 13 deletions

View File

@ -225,11 +225,6 @@ type drawImageCommand struct {
filter graphics.Filter
}
// VertexFloatNum returns the number of floats for one vertex.
func VertexFloatNum() int {
return theArrayBufferLayout.totalBytes() / opengl.Float.SizeInBytes()
}
func (c *drawImageCommand) String() string {
return fmt.Sprintf("draw-image: dst: %p <- src: %p, colorm: %v, mode %d, filter: %d", c.dst, c.src, c.color, c.mode, c.filter)
}

View File

@ -14,10 +14,6 @@
package graphicsutil
import (
"github.com/hajimehoshi/ebiten/internal/graphicscommand"
)
var (
theVerticesBackend = &verticesBackend{}
)
@ -28,20 +24,22 @@ type verticesBackend struct {
}
func (v *verticesBackend) slice(n int) []float32 {
const num = 256
const (
num = 1024
vertexFloatNum = 10
)
if n > num {
panic("not reached")
}
need := n * graphicscommand.VertexFloatNum()
need := n * vertexFloatNum
if v.head+need > len(v.backend) {
v.backend = nil
v.head = 0
}
if v.backend == nil {
size := 4 * graphicscommand.VertexFloatNum()
v.backend = make([]float32, size*num)
v.backend = make([]float32, vertexFloatNum*num)
}
s := v.backend[v.head : v.head+need]