Blinking when rendering text

Im using this code to render fonts, but I got this problems:

  • In windowed mode, theres no blinking but the text is drawn behind the poligons.
  • In fullscreen, text its ok, but the screen start to blink.

Can you guys help me?
(sorry about bad english)

void mundo(void)
{
glPushMatrix();
PrintString(“Hello”,0.02,0.98);
glPopMatrix();
glPushMatrix();
gluLookAt(cam.x,cam.y,cam.z,
tx,ty,tz,
rx,ry,rz);

  glCallList(Lsea);

  glPushMatrix();
    glCallList(Lterrain);
  glPopMatrix();
glPopMatrix();
glFlush ();

}

void PrintString(char *s,float x,float y) {
glPushAttrib(GL_LIGHTING_BIT|GL_DEPTH_BUFFER_BIT|GL_TEXTURE_BIT);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glRasterPos2f(x,y);
writef(s);
glRasterPos2f(0,0);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopAttrib();
}

void writef(char *s)
{
glPushAttrib(GL_LIST_BIT);
glListBase(fontOffset);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
glPopAttrib ();
}

Thanks for help people.

Hi !

Disable the depth buffer when you draw the text, then it will always be on top.

If the screen is “blinking”, it’s probably because you are not using deouble buffer rendering mode (you select that when you create the OpenGL context).

Mikael