PDA

View Full Version : Slow down when rendering fonts



lsdi
02-18-2002, 06:50 PM
My project slow down when im rendering fonts.

from 250 fps to 90 fps.

my code:
[CODE]

void buildlist(void)
{
GLuint i;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
fontOffset = glGenLists (128);
for (i = 32; i < 127; i++) {
glNewList(i+fontOffset, GL_COMPILE);
glBitmap(8, 13, 0.0, 2.0, 10.0, 0.0, fontes[i-32]);
glEndList();
}
}

void writef(char *s,float x, float y)
{
glPushMatrix();
glLoadIdentity();
glRasterPos2f(0,0);
glOrtho (0.0, 1.0, 0.0, 1.0, -2.0, 1.0);
glColor3f(1.0,1.0,1.0);
glRasterPos2f(x,y);
glPushAttrib(GL_LIST_BIT);
glListBase(fontOffset);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
glPopAttrib ();
glPopMatrix();

}

void hud(void) //THIS IS CALLED ON REDRAW
{
glPushAttrib(GL_LIGHTING_BIT|GL_DEPTH_BUFFER_BIT|G L_TEXTURE_BIT);
glDisable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
writef(FramesPerSecond,0.01,0.01);
writef("Something.",0.01,0.98);
glMatrixMode(GL_MODELVIEW);
glPopAttrib();
}
[CODE]