func (f *Font) DrawText2D(x int, y int, color [3]byte, scale float, txt string) (endw int, endh int) { gl.LoadIdentity() // gl.Translatef(0.0, 0.0, -2.0); glEnable2D() gl.Disable(gl.DEPTH_TEST) texture, initial, intermediarya, intermediary, w, h := f.setupTextRendering(color, txt) locX := gl.GLfloat(x) locY := gl.GLfloat(y) wi := gl.GLfloat(w) * gl.GLfloat(scale) he := gl.GLfloat(h) * gl.GLfloat(scale) /* Draw a quad at location */ gl.Begin(gl.QUADS) /* Recall that the origin is in the lower-left corner That is why the TexCoords specify different corners than the Vertex coors seem to. */ gl.TexCoord2f(0.0, 1.0) gl.Vertex2f(locX, locY) gl.TexCoord2f(1.0, 1.0) gl.Vertex2f(locX+wi, locY) gl.TexCoord2f(1.0, 0.0) gl.Vertex2f(locX+wi, locY+he) gl.TexCoord2f(0.0, 0.0) gl.Vertex2f(locX, locY+he) gl.End() endw, endh = f.teardownTextRendering(texture, initial, intermediarya, intermediary) gl.Enable(gl.DEPTH_TEST) glDisable2D() return }
func drawShip(angle gl.GLfloat) { gl.PushMatrix() gl.Translatef(x, y, 0.0) gl.Rotatef(angle, 0.0, 0.0, 1.0) if thrust { gl.Color3f(1.0, 0.0, 0.0) gl.Begin(gl.LINE_STRIP) gl.Vertex2f(-0.75, -0.5) gl.Vertex2f(-1.75, 0) gl.Vertex2f(-0.75, 0.5) gl.End() } gl.Color3f(1.0, 1.0, 0.0) gl.Begin(gl.LINE_LOOP) gl.Vertex2f(2.0, 0.0) gl.Vertex2f(-1.0, -1.0) gl.Vertex2f(-0.5, 0.0) gl.Vertex2f(-1.0, 1.0) gl.Vertex2f(2.0, 0.0) gl.End() if shield { gl.Color3f(0.1, 0.1, 1.0) gl.Begin(gl.LINE_LOOP) for rad := 0.0; rad < 12.0; rad += 1.0 { gl.Vertex2f( gl.GLfloat(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2), gl.GLfloat(2.0*math.Sin(2*float64(rad)/math.Pi))) } gl.End() } gl.PopMatrix() }
func drawBullets() { gl.Begin(gl.POINTS) gl.Color3f(1.0, 0.0, 1.0) for i := 0; i < MAX_BULLETS; i++ { if bullet[i].inuse { gl.Vertex2f(bullet[i].x, bullet[i].y) } } gl.End() }
func drawMap(cx, cy, zoom float64, triangles p2t.TriArray) { for i := 0; i < len(triangles); i++ { t := triangles[i] a := t.Point[0] b := t.Point[1] c := t.Point[2] //constrainedColor(t.constrained_edge[2]) gl.Begin(gl.LINES) gl.Vertex2f(float32(a.X), float32(a.Y)) gl.Vertex2f(float32(b.X), float32(b.Y)) gl.End() //constrainedColor(t.constrained_edge[0]) gl.Begin(gl.LINES) gl.Vertex2f(float32(b.X), float32(b.Y)) gl.Vertex2f(float32(c.X), float32(c.Y)) gl.End() //constrainedColor(t.constrained_edge[1]) gl.Begin(gl.LINES) gl.Vertex2f(float32(c.X), float32(c.Y)) gl.Vertex2f(float32(a.X), float32(a.Y)) gl.End() } }
func draw(triangles p2t.TriArray) { gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) for i := 0; i < len(triangles); i++ { var t = triangles[i] var a = t.Point[0] var b = t.Point[1] var c = t.Point[2] // Red gl.Color3f(1, 0, 0) gl.Begin(gl.LINE_LOOP) gl.Vertex2f(float32(a.X), float32(a.Y)) gl.Vertex2f(float32(b.X), float32(b.Y)) gl.Vertex2f(float32(c.X), float32(c.Y)) gl.End() } sdl.GL_SwapBuffers() }