func (sp *SpawnPoint) Render(pos mathgl.Vec2, width float32) { gl.Disable(gl.TEXTURE_2D) gl.Color4d(1, 1, 1, 0.1) gl.Begin(gl.QUADS) gl.Vertex2f(gl.Float(pos.X-width/2), gl.Float(pos.Y)) gl.Vertex2f(gl.Float(pos.X-width/2), gl.Float(pos.Y+width)) gl.Vertex2f(gl.Float(pos.X+width/2), gl.Float(pos.Y+width)) gl.Vertex2f(gl.Float(pos.X+width/2), gl.Float(pos.Y)) gl.End() }
func SetUniformF(shader, variable string, f float32) { prog, ok := shader_progs[shader] if !ok { if !warned_names[shader] { Warn().Printf("Tried to set a uniform in an unknown shader '%s'", shader) warned_names[shader] = true } return } bvariable := []byte(fmt.Sprintf("%s\x00", variable)) loc := gl.GetUniformLocation(gl.Uint(prog), (*gl.Char)(unsafe.Pointer(&bvariable[0]))) gl.Uniform1f(loc, gl.Float(f)) }
func (e *Entity) Render(pos mathgl.Vec2, width float32) { var rgba [4]float64 gl.GetDoublev(gl.CURRENT_COLOR, (*gl.Double)(&rgba[0])) e.last_render_width = width gl.Enable(gl.TEXTURE_2D) e.drawReticle(pos, rgba) if e.sprite.sp != nil { dxi, dyi := e.sprite.sp.Dims() dx := float32(dxi) dy := float32(dyi) tx, ty, tx2, ty2 := e.sprite.sp.Bind() gl.Begin(gl.QUADS) gl.TexCoord2d(gl.Double(tx), gl.Double(-ty)) gl.Vertex2f(gl.Float(pos.X), gl.Float(pos.Y)) gl.TexCoord2d(gl.Double(tx), gl.Double(-ty2)) gl.Vertex2f(gl.Float(pos.X), gl.Float(pos.Y+dy*width/dx)) gl.TexCoord2d(gl.Double(tx2), gl.Double(-ty2)) gl.Vertex2f(gl.Float(pos.X+width), gl.Float(pos.Y+dy*width/dx)) gl.TexCoord2d(gl.Double(tx2), gl.Double(-ty)) gl.Vertex2f(gl.Float(pos.X+width), gl.Float(pos.Y)) gl.End() } }