Re: [Plib-users] non-scaling fnt
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2003-07-20 15:20:00
|
Cameron Lerch wrote: > Is it possible to have a non-scaling fnt? Like if I were to place a > string at 0,0,0 and move away from it, I would like the font to remain > the same size, rather than be scaled smaller. I know I can do this with > GlutBitmapCharacter(), but I'd like to take advantage of the nice fonts > using fnt. If you want the text to remain in the same place ON THE SCREEN - then just switch to an Orthographic matrix before you render it. (glOrtho) However, if you want the text to appear to be attached to some 3D location in the scene (eg you want to label something so the label follows that object in space - yet remains legible no matter how far away that object is) - then you have a problem. (If that's what you want - then you probably also want the text to stay parallel to the plane of the screen.) You want OpenGL to project one corner of the text using perspective and have the other three corners be fixed screen space distances from it. Since all the vertices of the polygons in the text are transformed by the same GL_PROJECTION matrix, that's not directly possible. In the end, you have two choices: 1) Use a glOrtho projection matrix (so the size of the font stays the same no matter how far away it is) - and calculate the location of the origin text every frame by doing the projection calculations on that origin yourself. Push that location (with no rotation) as a matrix onto the modelview stack before you render the text. 2) Use the same perspective matrix as used when rendering the 3D object in the scene - but push a specially computed modelview matrix to scale the text in exactly the right way to compensate for the effects of perspective and to keep it parallel to the screen. Which of these you do (IMHO) depends on whether you want the text to be Z buffered or not. When you want it Z buffered, it's probably easiest to go the second route and render the text in the callback of a 3D object in the scene graph. When it's got to overlay everything else, it has to be rendered after everything else - or at least it has to be rendered at Z==Znear to enable it to occlude everything else. In that case, the first approach is probably easiest. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |