[Gambas-user] Rendering text with OpenGL example

Benoît Minisini gambas at ...1...
Sat Jan 11 11:59:53 CET 2014


Le 11/01/2014 09:14, Kevin Fishburne a écrit :
> On 01/10/2014 10:56 AM, terco IDE wrote:
>> Hi, does anyone has an example on rendering some text in a glArea with (or without) openGL?
>>
>> tnx!
>>
>> Saludos
>> Martin
>
> Yes (using OpenGL), but it's rather involved. I had an epic failure of
> hardware and human logic this week and am just wrapping up restoring
> sanity to my server and workstation, but give me a day or so and I'll
> give you the source code.
>
> It's my understanding that OpenGL has no native support of rendering
> text, that it must be done manually. I can also provide you with a
> couple of "fonts" that I created from ttf.
>
> Basically you take a ttf, type out all the characters you want in GIMP
> (I recommend keeping them in line with an ASCII table), then save each
> character into a separate png file with alpha. You then load these into
> OpenGL textures and render them as quads. The horrible bit (as if it
> weren't horrible enough) is getting the spacing right for different
> combinations of characters. You'll want to add drop shadows, beveling,
> etc. in GIMP as I don't know of a way to do this in OpenGL other than
> perhaps by using shaders (zero knowledge there).
>
> Using Gambas's native software text rendering libraries is slower but
> easier.
>
> Kevin

Why slower? You can use Gambas to create the font characters texture, 
and maintain a texture cache to not do that each time a character is drawn.

-- 
Benoît Minisini




More information about the User mailing list