From 395b46d8da3d94e5d72d69e627a3a612cab2f704 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 28 Oct 2018 23:00:10 +0900 Subject: [PATCH] graphicsutil: Remove dependency on graphicscommand --- internal/graphicscommand/command.go | 5 ----- internal/graphicsutil/vertices.go | 14 ++++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index 880a9c37e..95cbcb6a1 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -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) } diff --git a/internal/graphicsutil/vertices.go b/internal/graphicsutil/vertices.go index d76ef773f..cbda6f682 100644 --- a/internal/graphicsutil/vertices.go +++ b/internal/graphicsutil/vertices.go @@ -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]