Problem rendering text with a 3d enviroment

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;

    WWA[0],				//Where we're at
    WWLA[0],	//Where we're looking at (based on where we're at)
    0,					//Which direction is up

	glTranslatef(0.0f, 0.0f, 0.0f);

		glLoadIdentity();							// Reset The Current Modelview Matrix
	glMatrixMode(GL_PROJECTION);				// Go to projection mode
	glPushMatrix();								// Remember where we're at
	// 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)));
	// 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

	SwapBuffers(ghdc);// Swap the frame buffers.

//CheckMouse();	//Check for mouse input


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?

You’re pushing the projection matrix, and later pop the modelview matrix. You have to call glPopMatrix before you change the matrix mode back to GL_MODELVIEW.

callng pop matrix first didn’t work. i just get no text at all.

What’s your projection matrix ?

um…even though that was a straightforward question i dont understand it. to be honest, im not even that sure about projection matrix. i ‘think’ it dictates camera orientation but im not even sure about that, and even if i take that to be true im still not sure how to tell you what my projection matrix is.

Using glOrtho for your projection matrix might help.

glMatrixMode (GL_PROJECTION);
glOrtho (...);
// 2D texts here
glMatrixMode (GL_MODELVIEW);
// back to modelisation visualisation

i tried using ortho, but it doesn’t work. appears to clear to a black screen

glMatrixMode (GL_PROJECTION);
glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0);
// 2D texts here
glRasterPos2f(-0.45f+0.05ffloat(cos(cnt1)), 0.32ffloat(sin(cnt2)));
glPrint(“Active OpenGL Text With NeHe - %7.2f”, cnt1); // Print GL Text To The Screen

glMatrixMode (GL_MODELVIEW);

Have no time to type.