Rendering text with OpenGL

Discussion in 'Ruby' started by Ilmari Heikkinen, May 13, 2005.

  1. 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
     
    Ilmari Heikkinen, May 13, 2005
    #1
    1. Advertisements

  2. Ilmari Heikkinen

    George Ogata Guest

    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.
     
    George Ogata, May 13, 2005
    #2
    1. Advertisements

  3. Ilmari Heikkinen

    Bill Kelly Guest

    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
     
    Bill Kelly, May 13, 2005
    #3
  4. 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
     
    Ilmari Heikkinen, May 13, 2005
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.