Public Sub txtRendering2D(texto As String, p As Punto3d, Optional Altura As Single = 12, Optional _color As Long = Color.Blue, _BackColor As Long = -1)
Dim rectangulo As RectF
Dim imagen As New Image, pR As New Punto3d
imagen.Resize(200, 200) 'so Paint.Begin gives no error
Paint.Begin(imagen)
Paint.Font.Size = Altura
Paint.Brush = Paint.Color(_color)
rectangulo = Paint.TextSize(texto)
Paint.End
'this can't go into the Paint loop
imagen.resize(rectangulo.w, rectangulo.h)
imagen.Transparent(Color.Black)
If _backcolor > 0 Then imagen.Fill(_BackColor)
Paint.Begin(imagen)
Paint.Font.Size = Altura
Paint.Brush = Paint.Color(_color)
Paint.Text(texto, 0, rectangulo.h)
Paint.Fill
Paint.End
'imagen.Save("imagen.png") ' this is to check the Paint worked (and works!)
rotar3d(p, pr) ' custom rotation
gl.Enable(gl.TEXTURE_2D)
Gl.TexImage2D(imagen)
Glu.Build2DMipmaps(imagen)
Gl.TexParameteri(Gl.TEXTURE_2D, Gl.TEXTURE_MIN_FILTER, Gl.LINEAR_MIPMAP_NEAREST)
Gl.TexParameteri(Gl.TEXTURE_2D, Gl.TEXTURE_MAG_FILTER, Gl.LINEAR)
gl.Enable(gl.TEXTURE_2D)
gl.BindTexture(gl.TEXTURE_2D, hText[0])
Gl.Begin(Gl.QUADS)
gl.color3f(1, 1, 1)
' Bottom Left OF The Texture AND Quad
Gl.TexCoordf(0.0, 1.0)
Gl.Vertex3f(pr.x, pr.y, pr.z)
' Bottom Right OF The Texture AND Quad
Gl.TexCoordf(1.0, 1.0)
Gl.Vertex3f(pr.x + rectangulo.w, pr.y, pr.z)
' Top Right OF The Texture AND Quad
Gl.TexCoordf(1.0, 0.0)
Gl.Vertex3f(pr.x + rectangulo.w, pr.y + rectangulo.h, pr.z)
' Top Left OF The Texture AND Quad
Gl.TexCoordf(0.0, 0.0)
Gl.Vertex3f(pr.x, pr.y + rectangulo.h, pr.z)
Gl.End()