Search code examples
opengltextcolorsftgl

Cannot change font color with FTGL


How can I change the font color in FTGL?


Solution

  • Simply use a glColor call before asking the font to render; you may need to disable lighting depending on your situation. Here's an example for C++:

    FTFont *myfont= new FTBufferFont("myfontfile.ttf");
    
    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    
    glColor4d(1.0, 0.0, 0.0, 1.0);
    myfont->Render("Hello world");
    
    glPopAttrib();