I am working on the NeHeGL II basecode, but I am having a little problem. I am attempting to display a square, and then write text to the screen. The text shows up, but the square does not. Here is my drawing code:
void Draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The View
glTranslatef(0.0f,0.0f,-6.0f);
glRotatef(angle,0.0f,1.0f,0.0f);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f,-1.0f,0.0f);
glVertex3f(-1.0f,1.0f,0.0f);
glVertex3f(1.0f,1.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glEnd();
glLoadIdentity();
glColor3f(0.0f,0.3f,1.0f);
fEru.SetBase(32); // Adjust Base Start Pos (First Set of Fonts)
fEru.Print(20,30,"Dan Carroll Presents:"); // Print GL Text To The Screen
glColor3f(1.0f,1.0f,0.0f);
fEru.SetBase(32 - 128); // Adjust Base Start Pos (Second Set of Fonts)
fEru.Print(20,50,"Eru3D Test"); // Print GL Text To The Screen
glColor3f(1.0f,1.0f,1.0f);
fEru.SetBase(32);
fEru.Print(20,70,"FPS: %5.1f",frames);
glFlush (); // Flush The GL Rendering Pipeline
}
And the font print code:
GLvoid GLFont::Print(GLint x, GLint y, char *string, ...) // Where The Printing Happens
{
char text[256];
va_list ap;
if(string == NULL)
return;
va_start(ap, string);
vsprintf(text, string, ap);
va_end(ap);
glBindTexture(GL_TEXTURE_2D, fTexture[0]); // Select Our Font Texture
glDisable(GL_DEPTH_TEST); // Disables Depth Testing
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPushMatrix(); // Store The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glOrtho(0,fdWidth,0,fdHeight,-1,1); // Set Up An Ortho Screen
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPushMatrix(); // Store The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
glTranslated(x,fdHeight - y,0); // Position The Text (0,0 - Bottom Left)
glListBase(fBase - fStartPos); // Choose The Font Set (0 or 1)
glCallLists(strlen(text),GL_BYTE, text); // Write The Text To The Screen
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glPopMatrix(); // Restore The Old Projection Matrix
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
}
Any ideas on what the problem is? If you want more code, just ask.
And I did try moving the square code after the font code, but it still didn''t work.