Jump to content
  • Advertisement
Sign in to follow this  
Kitasia

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites



void Draw()
{
//Draw Background and characters

glDisable(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 Frame
Timer += timedelta;timedelta = float (SDL_GetTicks() - lasttickcount) / 1000;lasttickcount = SDL_GetTicks();
//Begin Operation
if (Timer >= 0)
{

//Sprite and collision operations
CalculateFrameRate();
Draw();
//Tests
TestGame();


//Quit
if(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 Loop
QuitGame();
return(0);
}




That's the sum of it.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!