pfText(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages pfText(3pf)NAME
pfNewText, pfGetTextClassType, pfAddString, pfRemoveString,
pfInsertString, pfReplaceString, pfGetString, pfGetNumStrings - Create,
modify, and query a 3D text node.
FUNCTION SPECIFICATION
#include <Performer/pf.h>
pfText * pfNewText(void);
pfType * pfGetTextClassType(void);
int pfAddString(pfText* text, pfString* string);
int pfRemoveString(pfText* text, pfString* str);
int pfInsertString(pfText* text, int index, pfString* str);
int pfReplaceString(pfText* text, pfString* old, pfString* new);
pfString * pfGetString(const pfText* text, int index);
int pfGetNumStrings(const pfString* string);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfText is derived from the parent class
pfNode, so each of these member functions of class pfNode are also
directly usable with objects of class pfText. Casting an object of class
pfText to an object of class pfNode is taken care of automatically. This
is also true for casts to objects of ancestor classes of class pfNode.
pfGroup * pfGetParent(const pfNode *node, int i);
int pfGetNumParents(const pfNode *node);
void pfNodeBSphere(pfNode *node, pfSphere *bsph, int mode);
int pfGetNodeBSphere(pfNode *node, pfSphere *bsph);
pfNode* pfClone(pfNode *node, int mode);
pfNode* pfBufferClone(pfNode *node, int mode, pfBuffer *buf);
int pfFlatten(pfNode *node, int mode);
int pfNodeName(pfNode *node, const char *name);
const char * pfGetNodeName(const pfNode *node);
pfNode* pfFindNode(pfNode *node, const char *pathName,
pfType *type);
pfNode* pfLookupNode(const char *name, pfType* type);
int pfNodeIsectSegs(pfNode *node, pfSegSet *segSet,
pfHit **hits[]);
void pfNodeTravMask(pfNode *node, int which, uint mask,
int setMode, int bitOp);
uint pfGetNodeTravMask(const pfNode *node, int which);
void pfNodeTravFuncs(pfNode* node, int which,
pfNodeTravFuncType pre, pfNodeTravFuncType post);
Page 1
pfText(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages pfText(3pf)
void pfGetNodeTravFuncs(const pfNode* node, int which,
pfNodeTravFuncType *pre, pfNodeTravFuncType *post);
void pfNodeTravData(pfNode *node, int which, void *data);
void * pfGetNodeTravData(const pfNode *node, int which);
void pfNodeTravMode(pfNode* node, int which, int mode,
int val);
int pfGetNodeTravMode(const pfNode* node, int which,
int mode);
Since the class pfNode is itself derived from the parent class pfObject,
objects of class pfText can also be used with these functions designed
for objects of class pfObject.
void pfUserDataSlot(pfObject *obj, int slot, void *data);
void pfUserData(pfObject *obj, void *data);
void* pfGetUserDataSlot(pfObject *obj, int slot);
void* pfGetUserData(pfObject *obj);
int pfGetNumUserData(pfObject *obj);
int pfGetNamedUserDataSlot(const char *name);
const char* pfGetUserDataSlotName(int slot);
int pfGetNumNamedUserDataSlots(void);
int pfDeleteGLHandle(pfObject *obj);
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfText can also be used with these functions
designed for objects of class pfMemory.
pfType * pfGetType(const void *ptr);
int pfIsOfType(const void *ptr, pfType *type);
int pfIsExactType(const void *ptr, pfType *type);
const char * pfGetTypeName(const void *ptr);
int pfRef(void *ptr);
int pfUnref(void *ptr);
int pfUnrefDelete(void *ptr);
int pfUnrefGetRef(void *ptr);
int pfGetRef(const void *ptr);
int pfCopy(void *dst, void *src);
int pfDelete(void *ptr);
int pfIsFluxed(void *ptr);
int pfCompare(const void *ptr1, const void *ptr2);
void pfPrint(const void *ptr, uint which, uint verbose,
FILE *file);
void * pfGetArena(void *ptr);
PARAMETERS
text identifies a pfText.
string identifies a pfString.
Page 2
pfText(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages pfText(3pf)DESCRIPTION
A pfText is analogous to a pfGeode. A pfText encapsulates pfStrings in a
scene graph as a pfGeode encapsulates pfGeoSets. A pfText is a leaf node
in the OpenGL Performer scene graph hierarchy and is derived from pfNode
so it can use pfNode API. A pfText is simply a list of pfStrings.
The bounding volume of a pfText is that which surrounds all its
pfStrings. Unless the bounding volume is considered static (see
pfNodeBSphere), OpenGL Performer will compute a new volume when the list
of pfStrings is modified by pfAddString, pfRemoveString, pfInsertString
or pfReplaceString. If the bounding box of a child pfString changes,
call pfNodeBSphere to tell OpenGL Performer to update the bounding volume
of the pfText.
pfNewText creates and returns a handle to a pfText. Like other pfNodes,
pfTexts are always allocated from shared memory and can be deleted using
pfDelete.
pfGetTextClassType returns the pfType* for the class pfText. The pfType*
returned by pfGetTextClassType is the same as the pfType* returned by
invoking pfGetType on any instance of class pfText. Because OpenGL
Performer allows subclassing of built-in types, when decisions are made
based on the type of an object, it is usually better to use pfIsOfType to
test if an object is of a type derived from a Performer type rather than
to test for strict equality of the pfType*'s.
pfAddString appends str to text's pfString list. pfRemoveString removes
str from the list and shifts the list down over the vacant spot. For
example, if str had index 0, then index 1 becomes index 0, index 2
becomes index 1 and so on. pfRemoveString returns a 1 if str was
actually removed and 0 if it was not found in the list. pfAddString and
pfRemoveString will cause OpenGL Performer to recompute new bounding
volumes for text unless it is configured to use static bounding volumes.
pfInsertString will insert str before the pfString with index index.
index must be within the range 0 to pfGetNumStrings(text).
pfReplaceString replaces old with new and returns 1 if the operation was
successful or 0 if old was not found in the list. pfInsertString and
pfReplaceString will cause OpenGL Performer to recompute new bounding
volumes for text unless it is configured to use static bounding volumes.
pfGetNumStrings returns the number of pfStrings in text. pfGetString
returns a handle to the pfString with index index or NULL if the index is
out of range.
Here is a sample code snippet demonstrating how to use pfText, pfFont,
and pfString to add 3D text to a scene graph:
/* Initialize Performer and create pfScene "scene" */
/* Get shared memory arena */
Page 3
pfText(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages pfText(3pf)
arena = pfGetSharedArena();
/* Append standard directories to Performer search path, PFPATH */
pfFilePath(".:/usr/share/Performer/data");
/* Create 3D message and place in scene. */
text = pfNewText();
pfAddChild(scene, text);
if (pfFindFile("Times-Elfin.of", path, R_OK))
{
str = pfNewString(arena);
pfStringMode(str, PFSTR_DRAWSTYLE, PFSTR_EXTRUDED);
pfStringMode(str, PFSTR_JUSTIFY, PFSTR_MIDDLE);
pfStringColor(str, 1.0f, 0.0f, 0.8f, 1.0f);
pfStringString(str, "Welcome to OpenGL Performer");
pfFlattenString(str);
pfAddString(text, str);
}
else
{
pfNotify(PFNFY_WARN,PFNFY_PRINT,"Couldn't find font file.");
exit(0);
}
SEE ALSO
pfGeoSet, pfNode, pfNodeTravFuncs, pfString, pfFont, pfDelete
Page 4