[Gambas-user] Rendering text with OpenGL example
Kevin Fishburne
kevinfishburne at ...1887...
Mon Jan 13 06:32:45 CET 2014
On 01/11/2014 05:59 AM, Benoît Minisini wrote:
> 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.
>
That's a good point. It's actually exactly what I do with the the
landscape tiles for my game using the DrawAlpha function. Composite each
tile using Gambas software operations, then offload it to an array of
OpenGL textures for on-screen rendering. I never thought the same could
be done with text.
In any case, let me know Martin if you're interested in my text
rendering code and bitmaps. I finally got everything up and running here.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list