Setting glutBitmapCharacter color?

colordot picture colordot · Apr 16, 2010 · Viewed 9.1k times · Source

Just wondering if someone can help me track down my issue with the following code where the text color is not being set correctly (its just rendering whatever color is in the background)

void RenderText(int x, int y, const char *string)
{
int i, len;

glUseProgram(0);

glLoadIdentity();
glColor3f(1.0f, 1.0f, 1.0f);
glTranslatef(0.0f, 0.0f, -5.0f);
glRasterPos2i(x, y);

glDisable(GL_TEXTURE_2D);
for (i = 0, len = strlen(string); i < len; i++)
{
    glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int)string[i]);
}
glEnable(GL_TEXTURE_2D);
}

I've checked all the usual things (I think), disabling texturing, setting color before rasterPos'ing, etc Ive disabled shaders but Im still having issues

Answer

Martin Hennig picture Martin Hennig · Nov 23, 2011

Looks like you've forgotten to glDisable(GL_LIGHTING) before drawing your string.