func DrawAABB(aabb Drawable, t float32, program gl.Program) { box := aabb.GetBox3D() nverts, normals := GetVerts() if box.Animator != nil { box.Animator(&box, t) } drawPos := box.Pos drawColor := box.Color drawSize := box.Size program.GetUniformLocation("SizeVec").Uniform3f(drawSize.X, drawSize.Y, drawSize.Z) program.GetUniformLocation("PosVec").Uniform3f(drawPos.X, drawPos.Y, drawPos.Z) gl.Color3f(drawColor.X, drawColor.Y, drawColor.Z) gl.EnableClientState(gl.VERTEX_ARRAY) gl.VertexPointer(3, 0, nverts) gl.EnableClientState(gl.NORMAL_ARRAY) gl.NormalPointer(0, normals) gl.DrawArrays(gl.QUADS, 0, 24) gl.DisableClientState(gl.NORMAL_ARRAY) gl.DisableClientState(gl.VERTEX_ARRAY) for it := aabb.GetChildren(); it != nil; it = it.Next() { DrawAABB(it.Value.(Drawable), t, program) } }
func (p *GLPainter) Flush() { if len(p.vertices) != 0 { gl.EnableClientState(gl.COLOR_ARRAY) gl.EnableClientState(gl.VERTEX_ARRAY) gl.ColorPointer(4, 0, p.colors) gl.VertexPointer(2, 0, p.vertices) // draw lines gl.DrawArrays(gl.LINES, 0, len(p.vertices)/2) gl.DisableClientState(gl.VERTEX_ARRAY) gl.DisableClientState(gl.COLOR_ARRAY) p.vertices = p.vertices[0:0] p.colors = p.colors[0:0] } }