pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
NAME
pfNewShaderObject, pfGetShaderObjectClassType,
pfGetShaderObjectShaderType, pfShaderObjectShaderType,
pfGetShaderObjectName, pfShaderObjectName, pfShaderObjectLoad,
pfShaderObjectSource, pfShaderSourceWithArgs, pfGetShaderObjectSource,
pfCompileStatusShaderObject, pfHandleShaderObject, pfAttrShaderObject -
Class for specifying GLSL shader objects
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfShaderObject* pfNewShaderObject(void *arena);
pfType* pfGetShaderObjectClassType(void);
int -
pfGetShaderObjectShaderType(const pfShaderObject* _shaderobject);
void pfShaderObjectShaderType(pfShaderObject* _shaderobject,
int shdType);
const char* -
pfGetShaderObjectName(const pfShaderObject* _shaderobject);
void pfShaderObjectName(pfShaderObject* _shaderobject,
const char *name);
void pfShaderObjectLoad(pfShaderObject* _shaderobject);
void pfShaderObjectSource(pfShaderObject* _shaderobject,
GLcharARB *src);
void pfShaderSourceWithArgs(pfShaderObject* _shaderobject,
GLint numStrings, const GLcharARB **src,
GLint *lengths);
char* -
pfGetShaderObjectSource(const pfShaderObject* _shaderobject);
int -
pfCompileStatusShaderObject(const pfShaderObject* _shaderobject);
GLhandleARB -
pfHandleShaderObject(const pfShaderObject* _shaderobject);
int pfAttrShaderObject(const pfShaderObject* _shaderobject,
int what);
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. Casting an
Page 1
pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
object of class pfShaderObject 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 pfShaderObject can also be used with these
functions designed for objects of class pfMemory.
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
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.
pfNewShaderObject creates and returns a handle to a pfShaderObject.
arena specifies a malloc arena out of which the pfShaderObject is
allocated or NULL for allocation off the process heap. pfShaderObjects
can be deleted with pfDelete.
Page 2
pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
pfGetShaderObjectClassType returns the pfType* for the class
pfShaderObject. The pfType* returned by pfGetShaderObjectClassType is
the same as the pfType* returned by invoking pfGetType on any instance of
class pfShaderObject. 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.
A pfShaderObject can be specified either by loading the source
explicitely by simply specifying the filename via pfShaderObjectName. 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 pfGetShaderObjectName. 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 pfShaderObjectLoad in order to load the source code
into the shader object.
The source code for the shader object can also be specified explicitely
via pfShaderObjectSource. The corresponding get method is
pfGetShaderObjectSource.
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
pfShaderObjectShaderType. One can also retreive the shader type for a
given pfShaderObject via pfGetShaderObjectShaderType.
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 pfGetShaderObjectCompileStatus 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 pfShaderObjectCompile. 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 pfGetShaderObjectHandle. The
handle gets created as needed during the compilation process. If the
pfShaderObject has not yet been compiled then the handle will be NULL.
Page 3
pfShaderObject(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
SEE ALSO
pfShaderProgram, pfGeoState, pfObject, pfFindFile.
Page 4