pfColortable(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAME
pfColortable, pfGetCurCtab - Specify color table properties Color table
class and related functions
FUNCTION SPECIFICATION
#include <Performer/pr/pfColortable.h>
pfColortable::pfColortable()
pfColortable::pfColortable(int size)
static pfType * pfColortable::getClassType(void);
int pfColortable::getCtabSize();
void pfColortable::apply();
int pfColortable::setColor(int index, pfVec4 &color);
int pfColortable::getColor(int index, pfVec4 &color);
pfVec4 * pfColortable::getColors();
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. This is also true
for ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, void *arena);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
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.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
Page 1
pfColortable(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
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.
new(arena) allocates a pfColortable from the specified memory arena, or
from the process heap if arena is NULL. new allocates a pfColortable
from the default memory arena (see pfGetSharedArena). Like other
pfObjects, pfColortables cannot be created statically, automatically on
the stack or in arrays. The default constructor returns a pfColortable
of 256 entries. Or an argument size may be provided to the constructor,
where size is the number of pfVec4 color elements to allocate for the
pfColortable. pfColortables should be deleted with pfDelete rather than
the delete operator.
The number of color elements in the pfColortable is returned by
pfColortable::getCtabSize.
pfColortable::getClassType returns the pfType* for the class
pfColortable. The pfType* returned by pfColortable::getClassType is the
same as the pfType* returned by invoking the virtual function getType 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 the member function isOfTypeto
test if an object is of a type derived from a Performer type rather than
to test for strict equality of the pfType*'s.
Use a pfColortable's apply member function to select it as the current,
global color table. 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
Page 2
pfColortable(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
pfGeoSets.
pfColortable::apply is a display-listable command. If a pfDispList has
been opened by pfDispList::open, pfColortable::apply will not have
immediate effect but will be captured by the pfDispList and will only
have effect when that pfDispList is later drawn with pfDispList::draw.
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]. The member functions setColor and getColor
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. The member
function getColors 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 pfGeoSet::setAttr to set the pfColortable of
a pfGeoState and with pfOverride to override subsequent colortable
changes.
Example 1:
/* Set up 'colorindexed' pfGeoState */
gstate->setAttr(PFSTATE_COLORTABLE, ctab);
gstate->setMode(PFSTATE_ENCOLORTABLE, PF_ON);
/* Attach gstate to gset */
gset->setGState(gstate);
/* Draw gset colorindexed with ctab */
gset->draw();
Example 2:
pfEnable(PFEN_COLORTABLE);
ctab->apply();
/*
* Override active pfColortable to 'ctab' and colorindex enable
* to PF_ON.
*/
pfOverride(PFSTATE_COLORTABLE | PFSTATE_ENCOLORTABLE, PF_ON);
Page 3
pfColortable(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
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.
SEE ALSO
pfDelete, pfDispList, pfEnable, pfGeoSet, pfGeoState, pfOverride, pfState
Page 4