OpenGL Font HELP!!!!

This topic is 4832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Sorry to practically double post but I noticed much more activity on this board. Anyway, could someone recommend me a good fast method of rendering text in openGL. I've tried gltext but the results were slow. When I used SDL to do all the rendering SDL_TTF made rendering flawless. But this switch to OpenGl is killing performance. It's driving me crazy!!!! Could someone please lend a hand? (or an arm for this matter). I don't want fancy text or anything like that, just plain simple text that blits fast. Thank you! [help]

Share on other sites
Check out the NeHe tutorials on three different fonts. You can also refer to my earlier post today which included a font class.

hth
F451

Share on other sites
Okay thanks, but before I go over this I'd like to add that even the setup on the OpenGl faq page went slow when I modified to to draw the font 5 times in different locations.

Update: The one on the faq page is ironically the one you gave me [bawling]. But I don't think I've tried your class. Here's hoping!

Share on other sites
Didn't have much luck. Without font my program ran about 75 fps. With 1 string, it ran at about 62 and with 5 it ran at about 32 and the font size was only 12. Am I missing something? [looksaround]

Share on other sites
Post up your render routine and I will take a look. I think you should get a better frame rate than that, so there might be something in there that is slowing it down.

Share on other sites

void Draw(){	//Draw Background and charactersglDisable(GL_TEXTURE_2D);glPushMatrix();statsFont->SetRGB(1.0f,1.0f,1.0f);for(int i = 0; i<5; i++){statsFont->SetPos2D(0,24+i*12);statsFont->Print("Hello World");	}glEnable(GL_TEXTURE_2D);glPopMatrix();SDL_GL_SwapBuffers();}int main(int argc, char* argv[])  {SDL_Init(SDL_INIT_EVERYTHING);srand ( time(NULL) );hxsSetupWindow(ScreenW, ScreenH,32,0,"Demo"); //using hxRender for some things SetView(0,0,ScreenW,ScreenH);LoadGame();statsFont = new CFont("Times New Roman", 12);for(;;){SDL_PollEvent(&event);//Prepare FrameTimer += timedelta;timedelta = float (SDL_GetTicks() - lasttickcount) / 1000;lasttickcount = SDL_GetTicks();//Begin Operationif (Timer >= 0){//Sprite  and collision operationsCalculateFrameRate();Draw();	//TestsTestGame();//Quitif(keys[SDLK_ESCAPE] == 1 || keys[SDLK_F1] == 1){break;}if(event.type==SDL_QUIT){break;}if(keys[SDLK_F2] == 1){GameReset = 1;}ResetGame();Timer = 0.0f;}//End Operation}//End LoopQuitGame();return(0);}

That's the sum of it.

Share on other sites
Odd. That draw routine looks fine (apart from the texture disable/enable dont match with push/pop matrix). I get 600FPS by dropping your entire draw routine contents into a small test harness. Image. Binary Double check your framerate calculations are being done properly. Even for an empty OpenGL window you should be getting hundreds if not thousands of frames per second - even with the FPS counter on the screen telling you that! Also, you might also want to properly switch to orthographic mode before doing the text draws, seeing as you want them as a screen overlay instead of in 3D space. Eitherway, the framerate calcs and the othomode should not account for a halving of your FPS for five messages. What is your machine/gfx card spec and window size btw?

F451

[Edited by - Fahrenheit451 on May 28, 2005 7:21:42 AM]

Share on other sites
I'm using windows XP with an integrated intel 8245G graphics card with 64MB. My window size is 640x480. Btw I don't hit 600 fps when I'm just clearing the screen. [lol] This anywhere near normal for a 2D game in SDL?

Share on other sites
Okay it must be my hardware then. I get about 50 fps from loading that binary. Umm suggestions? If not, your gfx card specs would be appreciated! It's time I updated anyway.

Share on other sites
just had a look at the nehe tutorial a couple of observatiosn
A/glPrint(..) is a very slow command, do not use this method if u wanna draw fast text (see www.opengl.org for info on creating text with textures)
B/its still using glaux.h which should be advoided at all costs

1. 1
2. 2
JoeJ
20
3. 3
4. 4
frob
12
5. 5

• 13
• 18
• 13
• 20
• 13
• Forum Statistics

• Total Topics
632194
• Total Posts
3004681

×