Archived

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

SkinnyM

Huge Speed Decrease. Please Help

Recommended Posts

Hello, I just finished my 2D font class. And finally i wanted to see what FPS i was running at. (I already had a timer class) So i set it up and display the FPS on the screen with this new 2D text class. The FPS is 12! That is absolutly terrible when all i am drawing is the text and 1 quad. So what i do, is stop drawing my text and instead write the same FPS to my log file. And i get FPS like 500-800 FPS. I was wondering if you could look at my draw function and tell me what is making it SLOW slow. Thanks void CWindowsFont::BuildFont(char *FontName, int Height) { HFONT font; HFONT oldfont; base = glGenLists(96); font = CreateFont(Height, 0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, FontName); oldfont = (HFONT)SelectObject(g_hDC, font); wglUseFontBitmaps(g_hDC, 32, 96, base); SelectObject(g_hDC, oldfont); DeleteObject(font); CLog::Get()->WriteLog(true, "Created 2D font %s at a height of %d sucessfully", FontName, Height); } void CWindowsFont::RenderText(int x, int y, char *String, ...) { va_list List; if (!strlen(String)) return; va_start(List, String); vsprintf(Buffer, String, List); va_end(List); glPushAttrib(GL_TRANSFORM_BIT | GL_VIEWPORT_BIT); glListBase(base-32); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glColor4ub(Red, Green, Blue, Alpha); glOrtho(0.0f, 640, 0.0f, 480.0f, -1.0f, 1.0f); glRasterPos2i(x, y); glCallLists(strlen(String), GL_UNSIGNED_BYTE, Buffer); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); glColor3f(255, 255, 255); } And if you see a problem, how can i speed it up? "What we do in life, echos in eternity" -- Gladiator [edited by - SkinnyM on January 4, 2004 8:47:12 PM]

Share this post


Link to post
Share on other sites
The problem turned out to be that when i was passing in the FPS to the RenderText function, i passed it in as a va_argument. And for some odddddddd reason, it was clipping the last number. So instead, i just used sprintf() and passed in a single string to the function and all works fine now. So it turned out to be nothing wrong with the opengl code. Now i am running at 600 FPS!



"What we do in life, echos in eternity" -- Gladiator

Share this post


Link to post
Share on other sites