PDA

View Full Version : Too Slow when rendering text



lsdi
01-11-2002, 03:32 PM
Whats wrong with this code? ... its slow down frames per second... half.




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)
{
glPushAttrib(GL_LIST_BIT);
glListBase(fontOffset);
glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *) s);
glPopAttrib ();
}

void PrintString(char *s,float x,float y) {
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);
glPushMatrix();
glLoadIdentity();
glOrtho (0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glRasterPos2f(x,y);
glColor3f(0.0,0.0,1.0);
writef(s);
glRasterPos2f(0,0);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopAttrib();

}

void mundo(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glPushMatrix();

CamQ.Update();
CamQ.PlaceCamera();
glColor4f(1.0,1.0,1.0,0.5);
glCallList(Lsea);
glCallList(Lterrain);
glPopMatrix();
PrintString("HELLO...",0.60,0.95);

}



Thanks http://www.opengl.org/discussion_boards/ubb/smile.gif

zed
01-11-2002, 11:00 PM
check the faq also on this site somewhere theres a page about doing text (comparrison of methods), using a single texture containing all the characters is generally the fastest way