Rendering text with OpenGL

I

Ilmari Heikkinen

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
 
G

George Ogata

Ilmari Heikkinen said:
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.
 
B

Bill Kelly

From: "George Ogata said:
Ilmari Heikkinen said:
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.html#FTGL

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
 
I

Ilmari Heikkinen

From: "George Ogata said:
Ilmari Heikkinen said:
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.html#FTGL

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.org/rcairo
[2] http://dark.fhtr.org/rcairo_tex.png
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top