pfTexEnv(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexEnv(3pf)NAME
pfNewTEnv, pfGetTEnvClassType, pfTEnvMode, pfGetTEnvMode,
pfTEnvBlendColor, pfGetTEnvBlendColor, pfApplyTEnv, pfGetCurTEnv -
Create, modify and query texture environment
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfTexEnv * pfNewTEnv(void *arena);
pfType * pfGetTEnvClassType(void);
void pfTEnvMode(pfTexEnv *tenv, int mode);
int pfGetTEnvMode(const pfTexEnv *tenv);
void pfTEnvBlendColor(pfTexEnv *tenv, float r, float g, float b,
float a);
void pfGetTEnvBlendColor(pfTexEnv *tenv, float* r, float* g,
float* b, float* a);
void pfApplyTEnv(pfTexEnv *tenv);
pfTexEnv * pfGetCurTEnv(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfTexEnv is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfTexEnv. Casting an object of
class pfTexEnv 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);
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfTexEnv can also be used with these functions
designed for objects of class pfMemory.
Page 1
pfTexEnv(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexEnv(3pf)
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
tenv identifies a pfTexEnv.
DESCRIPTION
pfNewTEnv creates and returns a handle to a pfTexEnv. arena specifies a
malloc arena out of which the pfTexEnv is allocated or NULL for
allocation off the process heap. pfTexEnvs can be deleted with pfDelete.
See the OpenGL glTexEnv(3g) man page for more details on texture
environments.
pfGetTEnvClassType returns the pfType* for the class pfTexEnv. The
pfType* returned by pfGetTEnvClassType is the same as the pfType*
returned by invoking pfGetType on any instance of class pfTexEnv.
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.
pfTEnvMode sets the texture environment mode. mode is a symbolic token
that specifies a texture environment mode and is one of the following:
PFTE_MODULATE
PFTE_BLEND
PFTE_DECAL
PFTE_REPLACE
PFTE_ADD
PFTE_ALPHA
The default mode is PFTE_MODULATE. pfGetTEnvMode returns the mode of
tenv. See the OpenGL glTexEnvf(3g) man page for more details on texture
environments.
npfTEnvBlendColor sets the texture environment blend color. This color
is used when the texture environment mode is PFTE_BLEND or PFTE_ADD. The
default OpenGL Performer texture environment blend color is [1,1,1,1].
Page 2
pfTexEnv(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexEnv(3pf)
It is different from the default OpenGL blend color of [0,0,0,0]. This
was done to maintain compatibility with previous OpenGL Performer
releases. pfGetTEnvBlendColor copies the texture environment blend color
into r, g, b, a.
pfApplyTEnv makes tenv the current texture environment. When texturing
is enabled (see below), this texture environment will be applied to all
geometry drawn after pfApplyTEnv is called. Only one pfTexEnv may be
active at a time although many may be defined. Modifications to tenv,
such as changing the blend color, will not have effect until pfApplyTEnv
is called with tenv.
For geometry to be textured, the following must be true:
1. Texturing must be enabled: pfEnable(PFEN_TEXTURE)
2. A pfTexEnv must be applied: pfApplyTEnv
3. A pfTexture must be applied: pfApplyTex
4. Geometry must have texture coordinates: pfGSetAttr,
PFGS_TEXCOORD2
The texture environment state element is identified by the PFSTATE_TEXENV
token. Use this token with pfGStateAttr to set the texture environment
of a pfGeoState and with pfOverride to override subsequent texture
environment changes.
Example 1:
/* Set up blue 'blend' texture environment */
tev = pfNewTEnv(NULL);
pfTEnvMode(tev, PFTE_BLEND);
pfTEnvBlendColor(tev, 0.0f, 0.0f, 1.0f);
/* Set up textured/blended pfGeoState */
pfGStateMode(gstate, PFSTATE_ENTEXTURE, PF_ON);
pfGStateAttr(gstate, PFSTATE_TEXENV, tev);
pfGStateAttr(gstate, PFSTATE_TEXTURE, tex);
/* Attach gstate to gset */
pfGSetGState(gset, gstate);
/* Set texture coordinate array. 'gset' is non-indexed */
pfGSetAttr(gset, PFGS_TEXCOORD2, PFGS_PER_VERTEX, tcoords, NULL);
/* Draw textured gset */
pfDrawGSet(gset);
Example 2:
Page 3
pfTexEnv(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages pfTexEnv(3pf)pfApplyTEnv(tev);
/* Override so that all textured geometry uses 'tev' */
pfOverride(PFSTATE_TEXENV, PF_ON);
pfApplyTEnv is a display-listable command. If a pfDispList has been
opened by pfOpenDList, pfApplyTEnv 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.
pfGetCurTEnv returns the currently active pfTexEnv or NULL if there is no
active pfTexEnv.
NOTES
PFTE_ALPHA is supported only on RealityEngine graphics systems.
SEE ALSO
pfDelete, pfDispList, pfEnable, pfGeoState, pfObject, pfState, pfTexture,
tevbind, tevdef, texbind, texdef, glTexEnv, glTexImage2D.
Page 4