I want to display 2D text ( ex shows FPS etc ) while running in 3D mode …
First I thought right before I go to display 2D text, I will save Current Projection matrix, and then Switch from gluPerspective() to glOrtho(), and I will be able to DIsplay the Text as If in the 2D mode, so while I move my Camera in 3D my Text will be displayed always in the same 2D position …
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,800,0,600,-1,1);
glMatrixMode(GL_MODELVIEW);
glTranslatef(400.0f, 300.0f, 0.0f);
glColor3f(1.0f, 1.0f, 1.0f);
PrintString(listBase, “TEST”);
glFlush();
SwapBuffers(g_HDC);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
In Other functions I setup The Font, Its type, Size, Delete etc …
This is my Print String Function
void PrintString(unsigned int base, char *str)
{
if ((base == 0) | | (str == NULL))
return;
glPushAttrib(GL_LIST_BIT);
glListBase(base - 32);
glCallLists(strlen(str), GL_UNSIGNED_BYTE, str);
glPopAttrib();
}