Advertisement

'Smart' text printing class

Started by February 01, 2003 11:15 AM
5 comments, last by Hawkeye3 22 years, 1 month ago
Hey. I''ve been working on a modified version of GLPrint that NeHe uses in his tutorials and have been trying to add some features but I''m not quite sure how to go about it. First, what is a good way to make a non-fixedwidth font? It sort of looks funny when theres so much extra space between characters. Secondly, I have no idea how I would go about adding something like WordWrap. For example I define a rectangle and if the string is larger than what can fit to the edge, it goes to the next line. I was also wondering how games do those cool text effects like blending in the string one letter at a time. With the current text class that simply isn''t possible. I guess using an array of actual char structures instead of just a string would be a step in the right direction. I suppose I can keep trying myself but I imagine this is a rather common thing and someone more knowledgeable could give me some insight Thanks
>>>...what is a good way to make a non-fixedwidth font...<<<
Do you mean like ''i'' is the same width as ''w''? If this is the case then you need per-char info on char width. If you''re using system fonts you can get this info from GetCharWidth32(...)

Wordwarp is actualy very simple. you have to tokanize text init words. Then for each word (before you draw it) see where it ends (sum up character lengths) and if its out of box go to next line.

fading in/out is not so easy if you want some fancy fx. [shameless plug I have so classes to work with this in my engine, along with windows TTF loading code. You can get it when NeHe uploades contest entry for MiniDemo contest. ]

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Advertisement
a MUCH better text tutorial:
http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg4.htm
a MUCH better text tutorial:
http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg4.htm
Hmm whats the performance hit like for using windows fonts in a game? Almost all of the games I see use actual bitmap files to render to the screen... Anyway, this looks to be a lot easier, I''ll have to study up on it.

Oh, and can''t wait to see your entry Darkwing

Thanks for the replies!
quote:
Original post by Hawkeye3
Hmm whats the performance hit like for using windows fonts in a game?

none whatsoever, if you use them properly.


[edited by - niyaw on February 2, 2003 3:29:35 PM]
Advertisement
there actualy is a (small) hit to performance rate whenusing a lot of system fonts. but it can be minimized by a simple trick. just render system fonts to texture and use them like bitmap fonts.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.

This topic is closed to new replies.

Advertisement