pfTexGen(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexGen(3pf)NAME
pfNewTGen, pfGetTGenClassType, pfTGenMode, pfGetTGenMode, pfTGenPlane,
pfGetTGenPlane, pfTGenPoint, pfGetTGenPoint, pfApplyTGen, pfGetCurTGen -
Create, modify and query texture coordinate generator
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfTexGen * pfNewTGen(void *arena);
pfType * pfGetTGenClassType(void);
void pfTGenMode(pfTexGen *tgen, int texCoord, int mode);
int pfGetTGenMode(const pfTexGen *tgen, int texCoord);
void pfTGenPlane(pfTexGen *tgen, int texCoord, float x, float y,
float z, float d);
void pfGetTGenPlane(pfTexGen *tgen, int texCoord, float* x,
float* y, float* z, float* d);
void pfTGenPoint(pfTexGen *tgen, int texCoord, float x, float y,
float z, float dx, float dy, float dz);
void pfGetTGenPoint(pfTexGen *tgen, int texCoord, float* x,
float* y, float* z);
void pfApplyTGen(pfTexGen *tgen);
pfTexGen* pfGetCurTGen(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfTexGen is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfTexGen. Casting an object of
class pfTexGen to an object of class pfObject is taken care of
automatically. This is also true for casts to objects of ancestor
classes 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 pfGetGLHandle(pfObject *obj);
int pfDeleteGLHandle(pfObject *obj);
Page 1
pfTexGen(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexGen(3pf)
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfTexGen 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
tgen identifies a pfTexGen
texCoord identifies a texture coordinate and is one of:
PF_S, PF_T, PF_R, PF_Q
DESCRIPTION
The pfTexGen capability is used to automatically generate texture
coordinates for geometry, typically for special effects like projected
texture, reflection mapping, and for light points (pfLPointState).
pfNewTGen creates and returns a handle to a pfTexGen. arena specifies a
malloc arena out of which the pfTexGen is allocated or NULL for
allocation off the process heap. pfTexGens can be deleted with pfDelete.
pfGetTGenClassType returns the pfType* for the class pfTexGen. The
pfType* returned by pfGetTGenClassType is the same as the pfType*
returned by invoking pfGetType on any instance of class pfTexGen.
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.
pfTGenMode sets the mode of tgen corresponding to texture coordinate
texCoord to mode. mode must be one of the following:
PFTG_OFF
Disables texture coordinate generation
Page 2
pfTexGen(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexGen(3pf)
PFTG_OBJECT_LINEAR
Generate texture coordinate as distance from plane in object
space.
PFTG_EYE_LINEAR
Generate texture coordinate as distance from plane in eye
space. The plane is transformed by the inverse of the ModelView
matrix when tgen is applied.
PFTG_EYE_LINEAR_IDENT
Generate texture coordinate as distance from plane in eye
space. The plane is not transformed by the inverse of the
ModelView matrix.
PFTG_SPHERE_MAP
Generate texture coordinate based on the view vector reflected
about the vertex normal in eye space.
PFTG_OBJECT_DISTANCE_TO_LINE
Coordinate will be the distance in object space from the vertex
to a line specified with a point and direction vector through
pfTGenPoint.
PFTG_EYE_DISTANCE_TO_LINE
Coordinate will be the distance in eye space from the eye to a
line specified with pfTGenPoint through the vertex.
PFTG_REFLECTION_MAP
Set texture coordinate to the view vector reflected about the
vertex normal in eye space.
PFTG_NORMAL_MAP
Set texture coordinate to the vertex normal in eye space.
See the OpenGL glTexGen(3g) man page for the specific mathematics of the
texture coordinate generation modes.
The default texture generation mode for all texture coordinates is
PFTG_OFF. pfGetTGenMode returns the mode of tgen.
pfTGenPlane sets the plane equation used for generating coordinates for
texture coordinate texCoord to aX + bY + cZ + d = 0. This plane equation
is used when tgen's mode is PFTG_EYE_LINEAR, PFTG_EYE_LINEAR_IDENT, or
PFTG_OBJECT_LINEAR but is ignored when its mode is PFTG_SPHERE_MAP,
PFTG_REFLECTION_MAP, or PFTG_NORMAL_MAP. The default plane equations are:
PF_S: (1, 0, 0, 0)
PF_T: (0, 1, 0, 0)
Page 3
pfTexGen(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexGen(3pf)
PF_R: (0, 0, 1, 0)
PF_Q: (0, 0, 0, 1)
pfGetTGenPlane will return the plane equation parameters for texture
coordinate texCoord of tgen in x, y, z, d. (If any of those arguments
are NULL, they will be ignored.)
pfTGenPoint sets a point and possible direction vector for use with point
and line based texture generation functions. pfGetTGenPoint will return
the point of tgen in x, y, z.
pfApplyTGen configures the graphics hardware with the texture coordinate
generating parameters encapsulated by tgen. Only the most recently
applied pfTexGen is active although any number of pfTexGen definitions
may be created. Texture coordinate generation must be enabled (-
pfEnable(PFEN_TEXGEN)) for tgen to have effect and modifications made to
tgen do not have effect until the next time pfApplyTGen is called.
pfGetCurTGen returns the currently active pfTexGen.
The pfTexGen state element is identified by the PFSTATE_TEXGEN token.
Use this token with pfGStateAttr to set the pfTexGen attribute of a
pfGeoState and with pfOverride to override subsequent pfTexGen changes:
Example 1:
/* Set up pfGeoState */
pfGStateMode(gstate, PFSTATE_ENTEXGEN, PF_ON);
pfGStateAttr(gstate, PFSTATE_TEXGEN, pfNewTGen(arena));
/* Attach gstate to gset */
pfGSetGState(gset, gstate);
/* Draw pfGeoSet whose texture coordinates are generated */
pfDrawGSet(gset);
Example 2:
/* Override so that all geometry is affected by 'tgen' */
pfEnable(PFEN_TEXGEN);
pfApplyTGen(tgen);
pfOverride(PFSTATE_TEXGEN | PFSTATE_ENTEXGEN, PF_ON);
pfApplyTGen is a display-listable command. If a pfDispList has been
opened by pfOpenDList, pfApplyTGen will not have immediate effect but
will be captured by the pfDispList and will only have effect when that
pfDispList is later drawn with pfDrawDList.
Page 4
pfTexGen(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexGen(3pf)SEE ALSO
pfDelete, pfDispList, pfGeoState, pfLPointState, pfMemory, pfObject,
pfOverride, texgen, glTexGen.
Page 5