Trying to print text after I have finished drawing a cube...

All right i’m trying to figure out what I’m doing wrong. I took one of nehe’s tutorials and want to see if i could add a fps counter. The fps counter works in another simple opengl app i wrote, so i know the fps routines are right.
The simple app i wrote had glPushMatrix and popmatrix, etc.
This one however is using glBegin and glEnd. Anway without confusing my self anymore and confusing you guys here is a sample of my code.

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[filter]);

glBegin(GL_QUADS);
// Front Face
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
// Back Face
glNormal3f( 0.0f, 0.0f,-1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
// Top Face
glNormal3f( 0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
// Bottom Face
glNormal3f( 0.0f,-1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
// Right face
glNormal3f( 1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
// Left Face
glNormal3f(-1.0f, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd();

//-----print fps on screen--------
glDisable(GL_TEXTURE_2D);
glLoadIdentity();
glColor3f(1.0, 1.0, 1.0);
glRasterPos2f(-0.5, -0.5); // Position The Text On The Screen
glNormal3f( 0.0f, 0.0f, 1.0f);
glPrint(“%1.2f fps”, t); //passes to glPrint function

Portions of the code come from many different other programs. I’m just learning here.

I could email the code if you need more details to see what i’m doing wrong. I’m assuming i’m messing up with the matrix mode and the re-sets.
Any help would be great.

Cheers

Oops never mind, i know what i did wrong, i forgot to add buildfont(); in the initgl() function.

Just another quick question. Can the pro’s check this part of the code and see if i’m doing anything wrong please?

GLvoid InitGL(GLvoid)
{
	
	LoadGLTextures();							// Load The Texture(s) ( NEW )
	//glEnable(GL_TEXTURE_2D);					// Enable Texture Mapping ( NEW )
	
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);		// This Will Clear The Background Color To Black
	glClearDepth(1.0);							// Enables Clearing Of The Depth Buffer
	glDepthFunc(GL_LESS);						// The Type Of Depth Test To Do
	glEnable(GL_DEPTH_TEST);					// Enables Depth Testing 
	glShadeModel(GL_SMOOTH);					// Enables Smooth Color Shading

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();							// Reset The Projection Matrix

	gluPerspective(45.0f, (GLfloat) kWindowWidth / (GLfloat) kWindowHeight, 0.1f, 100.0f);	
												
												
												// Calculate The Aspect Ratio Of The Window

	glMatrixMode(GL_MODELVIEW);
	
	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
	glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);
	
	glEnable(GL_LIGHT1);
	
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);			// Set The Blending Function For Translucency
	glColor4f(1.0f, 1.0f, 1.0f, 0.5);
	//-------font--------
	glDisable(GL_TEXTURE_2D);
	glLoadIdentity();
	
	glMatrixMode(GL_MODELVIEW);
	
	BuildFont();
	glLoadIdentity();
	//---font----
}

Am i using being redundant with glLoadIdentity and glmatrixMode?

Thanks

Yeah, your last calls to glMatrixMode and glLoadIdentity are redundant… other than that I don’t see anything wrong with your code. Once you set the matrix mode, it will stay in that mode until you change it with another call to glMatrixMode. If you do glLoadIdentity, that matrix will stay as the identity matrix until you call something that will change it, (ie. glLoadMatrix, glMultMatrix, glRotate, glScale, glRotate, glTranslate, glFrustum, glOrtho, gluPerspective, gluOrtho2D)