Use vertices for DrawTexture

This commit is contained in:
Hajime Hoshi 2015-01-16 01:01:45 +09:00
parent 2ec8c39cdd
commit b2924d193b

View File

@ -42,6 +42,8 @@ type TextureQuads interface {
// TODO: better name?
const stride = 4 * 4
var vertices = make([]float32, 0, stride*quadsMaxNum)
var initialized = false
func DrawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4][4]float64, quads TextureQuads, geo Matrix, color Matrix) error {
@ -65,7 +67,7 @@ func DrawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4
f := useProgramTexture(c, glMatrix(projectionMatrix), texture, geo, color)
defer f.FinishProgram()
vertices := make([]float32, 0, stride*quads.Len())
vertices := vertices[0:0]
for i := 0; i < quads.Len(); i++ {
x0, y0, x1, y1 := quads.Vertex(i)
u0, v0, u1, v1 := quads.Texture(i)
@ -99,8 +101,6 @@ func max(a, b float32) float32 {
return a
}
var vertices = make([]float32, 0, stride*quadsMaxNum)
func DrawRects(c *opengl.Context, projectionMatrix *[4][4]float64, r, g, b, a float64, quads VertexQuads) error {
if !initialized {
if err := initialize(c); err != nil {