Yves Martel (martel++at++signifi.com)
Wed, 06 May 1998 15:07:10 -0400
> I am having difficulties getting to grips with pfText,pfString and pfFont.
> I have managed to get some text on the screen, but changing the attributes
> of this text seems near impossible. I searched through the list's archives
> but found no solution to my problems.
> Three, possibly related questions are (in decreasing order of importance
> for me):
> 1) I tried using pfStringColor to change the strings colour, but had no
> success. The strings stay black (visible on a white background), even
> though a pfGetStringColor tells me that the RGB values are properly set to
> (1 1 1) . Should I reinitialise the string somehow after changing its
> colour?
I had the same problem until I disabled the shading:
pfDisable( PFEN_LIGHTING ) ;
... write text here ...
pfEnable( PFEN_LIGHTING ) ;
> 2) I scale the strings with pfStringMat etc. This works but it is a bit
> cumbersome. Is there no pfFontSize command? I cannot find it in the man
> pages.
in 2D text I use the font sizes in pfuMakeRasterXFont()...
> 3) ThreeD fonts look very nice, but in my application they are a bit
> superfluous and seem to put quite a load on my Indigo2. I just want a few
> lines of simple text : are there simpler fonts for this purpopse? (I tried
> using the FontManager and fmprstr() but that crashed the program).
Here is a piece of code I am using to write centered strings with 2D
text
in a 3D geometry:
//
--------------------------------------------------------------------------
void Text_Centered( pfChannel *channel, char *str, pfVec3 pos )
{
// --- no shading ---
pfDisable( PFEN_LIGHTING ) ;
// --- prepare a X font (select the font with "xfontsel") ---
static int height ;
static pfuXFont XFont ;
if ( ! height ) {
pfuMakeRasterXFont( "-sgi-rock-*-*-*-*-15-*-*-*-*-*-*-*", &XFont )
;
// --- center char verticaly ---
// height = pfuGetXFontHeight( &XFont ) ;
height = XFont.info->ascent / 2.0f ;
}
pfuSetXFont( &XFont ) ;
// --- compute a scale factor from pixel size to lenght at this depth
--- // at pos[1] (y), the width (x) of half-screen is: tan(fov/2) * y // the pixel size of half-screen is: res_x/2 float fov_h, fov_v ; int res_x, res_y ; channel->getSize( &res_x, &res_y ) ; channel->getFOV( &fov_h, &fov_v ) ; float fact = ( pfTan( fov_h*0.5f ) * pos[1] ) / (res_x * 0.5f) ;
// --- text color --- glColor3f( 1.0f, 1.0f, 1.0f ) ;
float larg = pfuGetXFontWidth( &XFont, str ) / 2.0f ; pfuDrawStringPos( str, pos[0] - (larg*fact), pos[1], pos[2] - (height*fact) ) ; pfEnable( PFEN_LIGHTING ) ; }
_______________________________________________________ Yves Martel Signifi.gVR mailto:Martel++at++signifi.com 417 St-pierre suite 208 Tel: (514) 288-1453 Montreal, QC, CANADA Fax: (514) 288-4112 H2Y 2M4 ======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:57:22 PDT