Hi, I have a program with a 3d enviroment and wanted to put some 2d text up for debugging. I’ve tried implimenting the NeHe tutorial, but have came to a problem. If i render the text i see nothing but the text, and i dont know how to fix it. the problem seems to be changing the matrix mode to display the text, but changing back after drawing the text doesn’t work.
void DrawScene()
{
char buffer[200];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
// glLoadMatrix(GL_MODELVIEW); // just to be safe
glLoadIdentity(); // Reset The Current Modelview Matrix
float sy = sin(yaw);
float cy = cos(yaw);
float sp = sin(pitch);
float cp = cos(pitch);
WWLA[0] = WWA[0] + sy * cp;
WWLA[1] = WWA[1] - sp;
WWLA[2] = WWA[2] + cy * cp;
gluLookAt(
WWA[0], //Where we're at
WWA[1],
WWA[2],
WWLA[0], //Where we're looking at (based on where we're at)
WWLA[1],
WWLA[2],
0, //Which direction is up
1,
0
);
DrawModels();
glTranslatef(0.0f, 0.0f, 0.0f);
glCallList(terrainList);
glLoadIdentity(); // Reset The Current Modelview Matrix
glMatrixMode(GL_PROJECTION); // Go to projection mode
glPushMatrix(); // Remember where we're at
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
// Pulsing Colors Based On Text Position
// glColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));
glColor4f(1.0f,0.0f,0.0f,1.0f);
// Position The Text On The Screen
sprintf(buffer, "blah blah blah");
glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)), 0.32f*float(sin(cnt2)));
glPrint("Active OpenGL Text With NeHe - %7.2f", cnt1); // Print GL Text To The Screen
cnt1+=0.051f; // Increase The First Counter
cnt2+=0.005f; // Increase The First Counter
glEnable(GL_TEXTURE_2D);
glEnable(GL_LIGHTING);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
SwapBuffers(ghdc);// Swap the frame buffers.
//CheckMouse(); //Check for mouse input
glFlush();
}
with glMatrixMode(GL_MODELVIEW) commented out i get the text but no models, with it not commented out i get no text but models. am i doing something wrong?