• Announcements

Archived

This topic is now archived and is closed to further replies.

faster text drawing

Recommended Posts

Hi, Is text drawing supposed to be such a framerate killer. When I draw one line of text on the screen it drops the framerate by about 30 fps.
void glDrawText(float x, float y, const char *strString, ...)
{
char		strText[256];							// This will hold our text to display
va_list		argumentPtr;							// This will hold the pointer to the argument list

// First we need to check if there was even a string given
if (strString == NULL)								// Check if a string was given
return;											// Don't render anything then

va_start(argumentPtr, strString);					// Parse the arguments out of the string
vsprintf(strText, strString, argumentPtr);			// Now add the arguments into the full string
va_end(argumentPtr);								// This resets and frees the pointer to the argument list.

OrthoMode(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

glRasterPos2f(x, y);

glPushAttrib(GL_LIST_BIT);							// This saves the list base information

glListBase(g_FontListID);							// This sets the lists base

glCallLists(strlen(strText), GL_UNSIGNED_BYTE, strText);

glPopAttrib();										// Return the display list back to it's previous state

PerspectiveMode();
}

Also, is there any way to do this without haveing to change into ortho mode to make the text appear. If I take out the orthomode switch, it doesn't draw. Also, the font is set up with the windows function CreateFont(). Is this the fastest way to do it or if there some other way. Thanks! [edited by - crossbow on August 14, 2002 10:07:52 PM]

Share on other sites
Changing to ortho every single time you print a string is
of course not a good idea. I''d suggest you leave all your
text printing to one place, switch to ortho, and print them
all in one go.

Kami no Itte ga ore ni zettai naru!

Share on other sites
>>Also, is there any way to do this without haveing to change into ortho mode to make the text appear.<<

not easily

>>If I take out the orthomode switch, it doesn''t draw. Also, the font is set up with the windows function CreateFont(). Is this the fastest way to do it <<

no

>>or if there some other way.<<

texture mapped fonts see www.opengl.org for an overview of text (by mark kilguard) also check the fa (both links on the right side)

http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share on other sites
quote:
Original post by crossbow
Hi,
Is text drawing supposed to be such a framerate killer.

no, but wgl fonts are framerate killers.

i ported CD3DFont class from dxsdk to gl with some good results.

Share on other sites
You might want to try plain texture mapped fonts, drawn with triangle strips.

Also, try to keep all your 2D rendering (text, hud etc) together so you only have to change the projection matrix once.

How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

• Partner Spotlight

• Forum Statistics

• Total Topics
627681
• Total Posts
2978611

• 13
• 12
• 10
• 12
• 22