[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rendering text with OpenGL

Ilmari Heikkinen

5/13/2005 10:44:00 AM

Hello,

Is there some simple and nice Ruby lib for rendering text into an OpenGL
texture? Something that takes a string and puts out a BGRA/ARGB pixels.

Or if that's a bad idea, what's the usual way of rendering nice-looking
text in GL? By nice-looking I mean variable width anti-aliased truetype
fonts with different font sizes, hinting, line heights and all the usual
font rendering lib niceties. Those niceties being the main reason I
don't really want to cook up my own font renderer :)

Thanks in advance,
Ilmari




3 Answers

George Ogata

5/13/2005 1:09:00 PM

0

Ilmari Heikkinen <kig@misfiring.net> writes:

> Hello,
>
> Is there some simple and nice Ruby lib for rendering text into an OpenGL
> texture? Something that takes a string and puts out a BGRA/ARGB pixels.
>
> Or if that's a bad idea, what's the usual way of rendering nice-looking
> text in GL? By nice-looking I mean variable width anti-aliased truetype
> fonts with different font sizes, hinting, line heights and all the usual
> font rendering lib niceties. Those niceties being the main reason I
> don't really want to cook up my own font renderer :)

If you're using GLUT, it's got simple text-rendering built-in.

If you just want to render the glyphs into a 2D array, libfreetype is
built for that. There are ruby bindings for it but I don't know what
they're like.

Otherwise, FTGL is nice, but I don't see any ruby bindings for it. It
has lazy-loaded, texture-based fonts for fast rendering, and extruded
geometry fonts for when you want render text as a solid object from
different angles. Hopefully it wouldn't be too hard to wrap some ruby
bindings around it.

HTH.



Bill Kelly

5/13/2005 5:21:00 PM

0

From: "George Ogata" <g_ogata@optushome.com.au>
> Ilmari Heikkinen <kig@misfiring.net> writes:
>
> > Is there some simple and nice Ruby lib for rendering text into an OpenGL
> > texture? Something that takes a string and puts out a BGRA/ARGB pixels.
> >
> > Or if that's a bad idea, what's the usual way of rendering nice-looking
> > text in GL? By nice-looking I mean variable width anti-aliased truetype
> > fonts with different font sizes, hinting, line heights and all the usual
> > font rendering lib niceties. Those niceties being the main reason I
> > don't really want to cook up my own font renderer :)
[...]
> Otherwise, FTGL is nice, but I don't see any ruby bindings for it. It
> has lazy-loaded, texture-based fonts for fast rendering, and extruded
> geometry fonts for when you want render text as a solid object from
> different angles. Hopefully it wouldn't be too hard to wrap some ruby
> bindings around it.

Nice !!!
http://homepages.paradise.net.nz/henryj/code/index...

I didn't know about FTGL... I'm currently using GLUT's simple
built-in fonts. I see FTGL already builds on Windows/Mac/*nix,
which is awesome.

Ilmari, I don't know what your time frame for this is but I'll
likely delve into creating some minimal ruby bindings for FTGL
in the next month or two. Looking at FTGL's test cases, it
seems nice and straightforward to call.
From test/FTGLBitmapFont-Test.cpp:

const char* const GOOD_ASCII_TEST_STRING = "test string";

void testDisplayList()
{
buildGLContext();

FTGLBitmapFont* bitmapFont = new FTGLBitmapFont(FONT_FILE);
bitmapFont->FaceSize(18);

int glList = glGenLists(1);
glNewList( glList, GL_COMPILE);

bitmapFont->Render(GOOD_ASCII_TEST_STRING);

glEndList();

CPPUNIT_ASSERT( glGetError() == GL_NO_ERROR);
}

So far I've always written ruby <-> C++ binding code by hand,
but I want to learn SWIG. Maybe this will be the time.

Ilmari, if FTGL looks appropriate for your project, let's keep
in touch so we don't end up duplicating effort in the ruby
bindings? Maybe we could create a rubyforge project.... ? Or ?


Regards,

Bill




Ilmari Heikkinen

5/13/2005 7:02:00 PM

0


On 13.5.2005, at 20:20, Bill Kelly wrote:

> From: "George Ogata" <g_ogata@optushome.com.au>
>> Ilmari Heikkinen <kig@misfiring.net> writes:
>>
>>> Is there some simple and nice Ruby lib for rendering text into an
>>> OpenGL
>>> texture? Something that takes a string and puts out a BGRA/ARGB
>>> pixels.
>>>
>>> Or if that's a bad idea, what's the usual way of rendering
>>> nice-looking
>>> text in GL? By nice-looking I mean variable width anti-aliased
>>> truetype
>>> fonts with different font sizes, hinting, line heights and all the
>>> usual
>>> font rendering lib niceties. Those niceties being the main reason I
>>> don't really want to cook up my own font renderer :)
> [...]
>> Otherwise, FTGL is nice, but I don't see any ruby bindings for it. It
>> has lazy-loaded, texture-based fonts for fast rendering, and extruded
>> geometry fonts for when you want render text as a solid object from
>> different angles. Hopefully it wouldn't be too hard to wrap some ruby
>> bindings around it.
>
> Nice !!!
> http://homepages.paradise.net.nz/henryj/code/index...
>
> I didn't know about FTGL... I'm currently using GLUT's simple
> built-in fonts. I see FTGL already builds on Windows/Mac/*nix,
> which is awesome.
>
> Ilmari, I don't know what your time frame for this is but I'll
> likely delve into creating some minimal ruby bindings for FTGL
> in the next month or two. Looking at FTGL's test cases, it
> seems nice and straightforward to call.
> [...]
>
> Ilmari, if FTGL looks appropriate for your project, let's keep
> in touch so we don't end up duplicating effort in the ruby
> bindings? Maybe we could create a rubyforge project.... ? Or ?
>

I played around a bit with rcairo[1] tonight and got it rendering into
a texture-ready String[2]. I'll probably go with that, at least for
now. Having access to polygon fonts from FTGL would be pretty awesome
though.

So, yeah, I'm open to suggestions.

[1] http://cairographics....
[2] http://dark.fhtr.org/rcai...