Jump to content

  • Log In with Google      Sign In   
  • Create Account

Render text in openGL


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Kaelb   Members   -  Reputation: 151

Like
0Likes
Like

Posted 12 August 2012 - 07:49 AM

Hey there.

I'm currently developing a GUI library from scratch, and after making the classes for buttons, windows, scrollbars etc I think its time to make them more user friendly by adding some text.

Today i tried to use the FTGL to draw some text, but the performance was very bad, just by drawing a window i got somewhat around 1300 fps, but if I drew it and a string ,with something like 20 characters, the framerate got around 200 fps using FTBitmapFont, it got even worse if I used FTPixmapFont.

I tried to use this library to avoid writting my own FreeType wrapper, basing myself on nehe's code that i saw here http://nehe.gamedev.net/tutorial/freetype_fonts_in_opengl/24001/ , though I think I could get a better performance from it.

Is there a better way to avoid these performance hits using FTGL?
Are there better text rendering APIs to use just to render some simple text on my GUI components? I don't really need anything complex, just some simple 2D text.

Cumpliments.

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2639

Like
0Likes
Like

Posted 12 August 2012 - 07:54 AM

Does it drop even more if you draw lets say the screen full of text?

The cost of just drawing a window is so small that adding anything to it could multiply the time it takes to render a frame...

o3o


#3 Kaelb   Members   -  Reputation: 151

Like
0Likes
Like

Posted 12 August 2012 - 08:13 AM

I will let you with two captions from my application, in the first one I have a window where I draw a button, one of my windows and a scroll bar, in the second one I draw the same components adding that "my text", and you can see the differences on the command line prompt in the left.

I think this was what you wanted me to show you...

http://i45.tinypic.com/2818owi.jpg
http://i50.tinypic.com/30ddt2p.jpg

#4 Waterlimon   Crossbones+   -  Reputation: 2639

Like
0Likes
Like

Posted 12 August 2012 - 08:40 AM

No i meant does the fps drop more if you add more text.

like what happens if you display a string of lets say 100 characters?

and do you draw the string yourself or does the library do it for you?

Edited by Waterlimon, 12 August 2012 - 08:41 AM.

o3o


#5 Kaelb   Members   -  Reputation: 151

Like
0Likes
Like

Posted 12 August 2012 - 08:45 AM

With a string of somewhat 150 characters the framerate goes around 14 fps.

Its the library that draws it.

#6 Waterlimon   Crossbones+   -  Reputation: 2639

Like
0Likes
Like

Posted 12 August 2012 - 08:54 AM

Random google search got me

"Getting rid of the "FaceSize" calls and using glScale instead resulted in a Framerate way above 100."

o3o


#7 Kaelb   Members   -  Reputation: 151

Like
0Likes
Like

Posted 12 August 2012 - 09:11 AM

tried it and doesn't seem to change the font size, and if i don't even call "FaceSize" it doesn't even renders any text.

Thanks for help, maybe i need to dig a bit more the library, though, the tutorial isn't the best...

#8 Waterlimon   Crossbones+   -  Reputation: 2639

Like
0Likes
Like

Posted 12 August 2012 - 12:15 PM

I believe the person who said that was calling it every frame or something. Try calling it once at the start...

o3o


#9 Lazy Foo   Members   -  Reputation: 1105

Like
0Likes
Like

Posted 12 August 2012 - 03:53 PM

The way I created an OpenGL FreeType Font is by basically creating a bitmap font from the TTF font. I would take all the glyphs and render the bitmap for each glyph and then put them all on one texture.

Then I would treat this font texture like a sprite sheet and render a sequence character sprites to render lines of text.

This managed to get me pretty good performance.

Learn to make games with my SDL 2 Tutorials


#10 Kaelb   Members   -  Reputation: 151

Like
0Likes
Like

Posted 12 August 2012 - 05:21 PM

That's what i intend to do, by doing that the only performance hit my application will take is creating the textures,
though that ain't a real problem because they will usually only be created on an init function

thanks for help, I will try that tomorrow.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS