pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
NAMEpfShaderManager - Create and manage mapping between shaders and scene
graph nodes.
FUNCTION SPECIFICATION
#include <Performer/pf/pfShaderManager.h>
pfShaderManager::pfShaderManager();
static pfType * pfShaderManager::getClassType(void);
int pfShaderManager::applyShader(pfNode *node,
pfShader *shader);
int pfShaderManager::removeShader(pfNode *node,
int shaderNum);
int pfShaderManager::getNumShaders(pfNode *node);
pfShader * pfShaderManager::getShader(pfNode *node,
int shaderNum);
int pfShaderManager::resolveShaders(pfNode *node);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfShaderManager is derived from the parent
class pfObject, so each of these member functions of class pfObject are
also directly usable with objects of class pfShaderManager. This is also
true for ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
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 pfShaderManager 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();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
Page 1
pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
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();
PARAMETERS
smgr identifies a pfShaderManager.
DESCRIPTION
These functions provide a means to apply pfShaders to scene graph nodes,
remove pfShaders from scene graph nodes and resolve sets of pfShaders
into representative pfPassLists for application to pfGeoSets.
new pfShaderManager creates and returns a handle to a pfShaderManager.
pfShaderManagers are always allocated from shared memory and cannot be
created statically, on the stack or in arrays.
pfShaderManager::getClassType returns the pfType* for the class
pfShaderManager. The pfType* returned by pfShaderManager::getClassType
is the same as the pfType* returned by invoking the virtual function
getType on any instance of class pfShaderManager. 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 isOfType 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.
pfShaderManager::applyShader adds shader to node's pfShader list. This
list is maintained internally by the pfShaderManager and is not a member
of pfNode. shader's reference count is incremented by one. Zero is
returned on success, negative one is returned on failure. Failure will
occur if either node or shader are NULL.
pfShaderManager::removeShader removes the pfShader indexed by shaderNum
from node's pfShader list. The reference count of the pfShader which is
removed is decremented by one. Zero is returned on success, negative one
is returned on failure. Failure will occur if either node is NULL or
shaderNum is less than zero or greater than the greatest pfShader index
for node.
pfShaderManager::getNumShaders returns the number of pfShaders in node's
pfShaderList. Returns negative one on failure which will occur if node
is NULL. If node is non-NULL but has had no pfShaders applied to it,
zero is returned.
Page 2
pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
pfShaderManager::removeShader returns a handle to the pfShader indexed by
shaderNum in node's pfShader list. The reference count of the returned
pfShader is not incremented. It is up to the caller to handle this.
NULL is returned on failure which will occur if either node is NULL or
shaderNum is less than zero or greater than the greatest pfShader index
for node.
pfShaderManager::resolveShaders performs a depth first traversal of the
sub-graph whose root is node. At each node in the sub-graph, the
pfShaderManager determines which, if any, pfShaders have been applied to
the current node and pushes these onto the shader stack.
If the current node is a group node then pfShaderManager::resolveShaders
continues its traversal into the current node's children. If the current
node is a pfGeode then a pfPassList must be constructed and applied to
all pfGeoSets in the pfGeode. To avoid creating unnecessary, duplicate
pfPassLists, the pfShaderManager maintains a dictionary of pfPassLists
that it has already created. This dicionary is searchable by the shader
stack from which each pfPassList entry was created. If the current
shader stack corresponds to a shader stack in the dictionary, the
corresponding pfPassList is retrieved from the dictionary and it is
applied to all pfGeoSets of the current pfGeode. If no match for the
current shader stack can be found in the dictionary, then a new
pfPassList must be created and added to the dictionary. To create a new
pfPassList, a new pfPassList is allocated and the pfPassLists of each
pfShader in the shader stack are appended to it. This new pfPassList and
the corresponding shader stack are added to the dictionary and the
pfPassList is applied to all pfGeoSets of the current pfGeode.
When leaving nodes, the pfShaderManager removes any pfShaders from the
shader stack which were applied at the current node. In this way, the
net effect of the shader stack is for pfShaders which are applied to
group nodes to be inherited by child nodes.
When traversing the scene graph, the pfShaderManager keeps a stack of
pfNameSpace named data that it encounters. Each time it enters a group
node, the pfShaderManager puts the list of names attached to that node
into a stack. When the pfShaderManager encounters pfGeoSets and
determines which pfPassList to use, it traverses the pfPassList and
resolves any names that the individual passes refer to and forwards them
to the passes. If the data is of an inappropriate type, a warning is
printed. With this method of name resolution, names that are closer to
the pfGeoSets on the path towards the root take precedence over those
that are farther.
NOTESBUGSSEE ALSO
pfShader
Page 3