pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages
NAME
pfNewShaderManager, pfGetShaderManagerClassType,
pfShaderManagerApplyShader, pfShaderManagerRemoveShader,
pfGetShaderManagerNumShaders, pfGetShaderManagerShader,
pfShaderManagerResolveShaders - Create and manage mapping between shaders
and scene graph nodes.
FUNCTION SPECIFICATION
#include <Performer/pf.h>
pfShaderManager * pfNewShaderManager(void);
pfType * pfGetShaderManagerClassType(void);
int pfShaderManagerApplyShader(pfShaderManager* smgr,
pfNode *node, pfShader *shader);
int pfShaderManagerRemoveShader(pfShaderManager* smgr,
pfNode *node, int shaderNum);
int pfGetShaderManagerNumShaders(pfShaderManager* smgr,
pfNode *node);
pfShader * pfGetShaderManagerShader(pfShaderManager* smgr,
pfNode *node, int shaderNum);
int pfShaderManagerResolveShaders(pfShaderManager* smgr,
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. Casting an
object of class pfShaderManager 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 pfDeleteGLHandle(pfObject *obj);
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.
Page 1
pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf 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);
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.
pfNewShaderManager 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.
pfGetShaderManagerClassType returns the pfType* for the class
pfShaderManager. The pfType* returned by pfGetShaderManagerClassType is
the same as the pfType* returned by invoking pfGetType 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 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.
pfShaderManagerApplyShader 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.
pfShaderManagerRemoveShader 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.
pfGetShaderManagerNumShaders returns the number of pfShaders in node's
Page 2
pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages
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.
pfShaderManagerRemoveShader 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.
pfShaderManagerResolveShaders 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 pfShaderManagerResolveShaders
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.
Page 3
pfShaderManager(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages
NOTESBUGSSEE ALSO
pfShader
Page 4