Domanda

How can I change the font color in FTGL?

È stato utile?

Soluzione

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();

Altri suggerimenti

This worked for me:

FTGLPixmapFont font("Myfont.ttf");

glPushAttrib(GL_ALL_ATTRIB_BITS);

glPixelTransferf(GL_RED_BIAS, red - 1);
glPixelTransferf(GL_GREEN_BIAS, green - 1);
glPixelTransferf(GL_BLUE_BIAS, blue - 1);

font.Render(str, -1, FTPoint(x, y));

glPopAttrib();

You can add another line for GL_ALPHA_BIAS if you want your text to be transparent.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top