pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAMEpfShaderObject - Class for specifying GLSL shader objects
FUNCTION SPECIFICATION
#include <Performer/pr/pfShaderObject.h>
pfShaderObject::pfShaderObject();
pfShaderObject::pfShaderObject(int type, GLint numStrings,
const GLcharARB **strings=NULL, GLint *lengths=NULL);
int pfShaderObject::getShaderObject() const;
int pfShaderObject::setShaderType(int shdType);
const char* pfShaderObject::getName() const;
void pfShaderObject::setName(const char *name);
void pfShaderObject::load();
void pfShaderObject::setSource(GLcharARB *src);
void pfShaderObject::setSource(GLint numStrings,
const GLcharARB **src, GLint *lengths);
char* pfShaderObject::getSource() const;
int pfShaderObject::getCompileStatus() const;
GLboolean pfShaderObject::compile(char **log = NULL);
GLhandleARB pfShaderObject::getHandle() const;
int pfShaderObject::getAttr(int what) const;
pfType * pfShaderObject::getClassType(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfShaderObject is derived from the parent
class pfObject, so each of these member functions of class pfObject are
also directly usable with objects of class pfShaderObject. 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);
Page 1
pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
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 pfShaderObject 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);
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
The pfShaderObject is a class that encapsulates the functionality
associated with either vertex or fragment programs used by OpenGL's
shading language (GLSL).
A pfShaderObject is represented by a string containing the source code
and a shader type. A collection of pfShaderObjects can be assembled to
form a valid pfShaderProgram which can then be used as a piece of state
used by pfGeoState via the PFSTATE_SHADPROG attribute.
new(arena) allocates a pfShaderObject from the specified memory arena, or
from the heap if arena is NULL. new allocates a pfShaderObject from the
default memory arena (see pfGetSharedArena). Like other pfObjects,
pfShaderObjects cannot be created statically, automatically on the stack
or in arrays. pfShaderObjects should be deleted with pfDelete rather
than the delete operator.
pfShaderObject::getClassType returns the pfType* for the class
pfShaderObject. The pfType* returned by pfShaderObject::getClassType is
the same as the pfType* returned by invoking the virtual function
getType on any instance of class pfShaderObject. Because OpenGL
Page 2
pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
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.
A pfShaderObject can be specified either by loading the source
explicitely by simply specifying the filename via
pfShaderObject::setName. The location for shader objects specified by
filename correspond to the semantics of pfFindFile and hence the PFPATH
environment variable can be used to specify the location of source files.
In order to retreive the name of the currently shader source you can use
pfShaderObject::getName. If the return srting is NULL it means that the
source is inlined and not loaded from an external file. If the shader
source is loaded from a file one must also call pfShaderObject::load in
order to load the source code into the shader object.
The source code for the shader object can also be specified explicitely
via pfShaderObject::setSource. The corresponding get method is
pfShaderObject::getSource.
In addition to setting the source in the form of either a filename or an
ASCII string one must also specify the shader type for a pfShaderObject.
By default this is set to -1 (invalid) and must be set to either
PFSHAD_FRAGMENT_SHADER or PFSHD_VERTEX_SHADER via
pfShaderObject::setShaderType. One can also retreive the shader type for
a given pfShaderObject via pfShaderObject::getShaderType.
If either the source code for the shader object or the type for the
shader object have changed the compilation status for the shader object
will change. One can determine the necessity for recompiling a given
pfShaderObject by calling pfShaderObject::getCompileStatus which will
return 1 if recompilation is required and 0 otherwise. This is used
internally to determine if a pfShaderProgram needs to be re-linked and
hence shouldn't normally be called from a user side program.
A pfShaderObject may be compiled via pfShaderObject::compile. The log
for the compilation process will be stored in the log parameter. If
successful the compilation will return 1 and 0 otherwise.
Once a pfShaderObject has been bound to the current graphics context it
is possible to retreive it's GL handle via pfShaderObject::getHandle. The
handle gets created as needed during the compilation process. If the
pfShaderObject has not yet been compiled then the handle will be NULL.
SEE ALSO
pfShaderProgram, pfGeoState, pfObject, pfFindFile.
Page 3