pfGProgram(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAMEpfGProgram - Generic/GPU program base class
FUNCTION SPECIFICATION
#include <Performer/pr/pfGProgram.h>
pfGProgram::pfGProgram();
pfType * pfGProgram::getClassType(void);
int pfGProgram::loadProgram(const char *filename);
void pfGProgram::setProgram(const char *code);
void pfGProgram::setProgram(const char *code, int length);
void pfGProgram::getProgram(char **code);
int pfGProgram::getProgramLength();
int pfGProgram::getNativeProgramLength();
int pfGProgram::isValid();
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfGProgram is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfGProgram. 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 pfGProgram 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);
Page 1
pfGProgram(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
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 pfGProgram is a general class that is used to set GPU programs,
specifically pfVertexProgram and pfFragmentProgram (see the respective
man pages). GPU is a programmable graphics processing unit of a modern
graphics hardware, used for example in Onyx4. Vertex programs are used
by the GPU to modify various parameters of each vertex. Similarly,
fragment programs are used to modify the color and depth value of each
fragment, pixel as it is being rendered. A description of vertex and
fragment program instruction set is beyond the scope of this man page.
You can find it in OpenGL extension registry at
http://oss.sgi.com/projects/ogl-sample/registry/ under
GL_ARB_vertex_program and GL_ARB_fragment_program.
new(arena) allocates a pfGProgram from the specified memory arena, or
from the heap if arena is NULL. new allocates a pfGProgram from the
default memory arena (see pfGetSharedArena). Like other pfObjects,
pfGPrograms cannot be created statically, automatically on the stack or
in arrays. pfGPrograms should be deleted with pfDelete rather than the
delete operator.
pfGProgram::getClassType returns the pfType* for the class pfGProgram.
The pfType* returned by pfGProgram::getClassType is the same as the
pfType* returned by invoking the virtual function getType on any
instance of class pfGProgram. 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.
A pfGProgram is a sequence of assembly-like instructions that are
specified in a string, with new line character separating each
instruction, or from a text file. If the program is specified in a
string, you use method pfGProgram::setProgram. The first parameter is
the string defining the program. Optionally, you can specify the length,
in case you want to load only part of the string. If the program is
loaded from a text file, you use the method pfGProgram::loadProgram.
Page 2
pfGProgram(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
You can apply the pfGProgram using pfGProgram::apply, but only in the
draw process. Once the pfGProgram has been applied, you can query its
state using the following methods: pfGProgram::getProgramLength, which
return the number of instructions of the program,
pfGProgram::getNativeProgramLength, which returns the number of
instructions used by the specific GPU, and pfGProgram::isValid, which
returns 1 if the program has been successfully loaded into the GPU.
You should not use a pfGProgram directly, but one if the classes
subclassed from it. Currently, there are two classes of specific GPU
programs subclassed from pfGProgram: pfVertexProgram and
pfFragmentProgram. A pfVertexProgram or a pfFragmentProgram programs is
set in a pfGeoState and they are enabled in a pfGeoState. Also, the user
parameters for the vertex and fragment programs can be defined using the
class pfGProgramParams. See the man pages for pfVertexProgram,
pfFragmentProgram, and pfGProgramParams and the sample code in
/usr/share/Performer/src/pguide/libpf/C++/gprogram.C.
SEE ALSO
pfVertexProgram, pfFragmentProgram, pfGProgramParms, pfGeoState,
pfTexture, pfObject.
Page 3