pfColortable(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
NAME
pfNewCtab, pfGetCtabClassType, pfGetCtabSize, pfApplyCtab, pfCtabColor,
pfGetCtabColor, pfGetCtabColors, pfGetCurCtab - Specify color table
properties
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfColortable * pfNewCtab(int size, void *arena);
pfType * pfGetCtabClassType(void);
int pfGetCtabSize(const pfColortable *ctab);
void pfApplyCtab(pfColortable *ctab);
int pfCtabColor(pfColortable *ctab, int index,
pfVec4 color);
int pfGetCtabColor(const pfColortable *ctab, int index,
pfVec4 color);
pfVec4 * pfGetCtabColors(const pfColortable *ctab);
pfColortable * pfGetCurCtab(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfColortable is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfColortable. Casting an object of
class pfColortable 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 pfColortable can also be used with these
functions designed for objects of class pfMemory.
Page 1
pfColortable(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
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);
DESCRIPTION
A pfColortable is a 'color indexing' mechanism used by pfGeoSets. It is
not related to the graphics library hardware rendering notion of color
index mode. If pfColortable operation is enabled, pfGeoSets will be
drawn with the colors defined in the current globally active pfColortable
rather than using the pfGeoSet's own local color list. This facility can
be used for instant large-scale color manipulation of geometry in a
scene.
pfNewCtab creates and returns a handle to a pfColortable. arena
specifies a malloc arena out of which the pfColortable is allocated or
NULL for allocation off the process heap. size is the number of pfVec4
color elements to allocate for the pfColortable. pfColortables can be
deleted with pfDelete.
The number of color elements in the pfColortable is returned by
pfGetCtabSize.
pfGetCtabClassType returns the pfType* for the class pfColortable. The
pfType* returned by pfGetCtabClassType is the same as the pfType*
returned by invoking pfGetType on any instance of class pfColortable.
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 pfIsOfTypeto test if an object is of a type derived from a
Performer type rather than to test for strict equality of the pfType*'s.
pfApplyCtab selects ctab as the current, global pfColortable. If
colorindex mode is enabled (pfEnable(PFEN_COLORTABLE)), then all
subsequent pfGeoSets will use the pfVec4 array supplied by the global
color table rather than their own local color array. Colorindex mode
works for both indexed and non-indexed pfGeoSets.
pfApplyCtab is a display-listable command. If a pfDispList has been
opened by pfOpenDList, pfApplyCtab will not have immediate effect but
will be captured by the pfDispList and will only have effect when that
Page 2
pfColortable(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
pfDispList is later drawn with pfDrawDList.
pfGetCurCtab returns the currently active pfColortable or NULL if there
is none active.
Colors in a pfColortable are pfVec4's which specify red, green, blue, and
alpha in the range [0..1]. pfCtabColor and pfGetCtabColor respectively
set and get the color at index index. To support high performance
manipulation of colortables, OpenGL Performer allows direct access to the
array of pfVec4 colors of a pfColortable. pfGetCtabColors returns a
pointer to this array which may be manipulated directly. However care
must be taken not to write data outside the array limits.
The pfColortable state element is identified by the PFSTATE_COLORTABLE
token. Use this token with pfGStateAttr to set the pfColortable of a
pfGeoState and with pfOverride to override subsequent colortable changes.
Example 1:
/* Set up 'colorindexed' pfGeoState */
pfGStateAttr(gstate, PFSTATE_COLORTABLE, ctab);
pfGStateMode(gstate, PFSTATE_ENCOLORTABLE, PF_ON);
/* Attach gstate to gset */
pfGSetGState(gset, gstate);
/* Draw gset colorindexed with ctab */
pfDrawGSet(gset);
Example 2:
pfEnable(PFEN_COLORTABLE);
pfApplyCtab(ctab);
/*
* Override active pfColortable to 'ctab' and colorindex enable
* to PF_ON.
*/
pfOverride(PFSTATE_COLORTABLE | PFSTATE_ENCOLORTABLE, PF_ON);
NOTES
pfColortables can be used to simulate FLIR (Forward Looking Infrared) and
NVG (Night Vision Goggles) and for monochrome display devices which
separate video components for stereo display purposes. More flexible FLIR
and NVG simulation is available through the use of indexed pfGeoStates.
Page 3
pfColortable(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
SEE ALSO
pfDelete, pfDispList, pfEnable, pfGeoSet, pfGeoState, pfOverride, pfState
Page 4