I am rendering some text in the upper left corner of my window with the following code, using glutBitmapCharacter:
// color = white
glColor3f(1,1,1);
// set orthographic projection
glMatrixMode( GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, (GLfloat)win_width, 0.0, (GLfloat)win_height);
// invert the y axis, down is positive
glScalef(1, -1, 1);
// mover the origin from the bottom left corner
// to the upper left corner
glTranslatef(0, -win_height, 0);
// switch to model view and save current matrix
glMatrixMode( GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
// render text
string str = "some text";
for (int i = 0; i < (int) str.length(); i++)
{
c = str[i];
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, c);
}
// go back to saved matrix in model view
glPopMatrix();
// go back to saved matrix in projection (perspective)
glMatrixMode(GL_PROJECTION);
glPopMatrix();
// change to model view
glMatrixMode(GL_MODELVIEW);
The problem is that the text is not white, it’s black! What am I doing wrong?