pfGProgram(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
NAME
pfNewGProgram, pfGetGProgramClassType, pfGProgramLoadProgram,
pfGProgramProgram, pfGProgramProgramLen, pfGetGProgramProgram,
pfGetGProgramProgramLength, pfGetGProgramNativeProgramLength,
pfGProgramIsValid, pfGProgramApply - Generic/GPU program base class
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfGProgram* pfNewGProgram(void *arena);
pfType* pfGetGProgramClassType(void);
int pfGProgramLoadProgram(pfGProgram* _gprogram,
const char *filename);
void pfGProgramProgram(pfGProgram* gprog, const char *code);
void pfGProgramProgramLen(pfGProgram* gprog, const char *code,
int length);
void pfGetGProgramProgram(const pfGProgram* gprog, char **code);
int pfGetGProgramProgramLength(pfGProgram* gprog);
int pfGetGProgramNativeProgramLength(pfGProgram* gprog);
int pfGProgramIsValid(pfGProgram* gprog);
void pfGProgramApply(pfGProgram* gprog);
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. Casting an object of
class pfGProgram 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);
Page 1
pfGProgram(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
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.
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
gprog identifies a pfGProgram
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.
pfNewGProgram creates and returns a handle to a pfGProgram. arena
specifies a malloc arena out of which the pfGProgram is allocated or NULL
for allocation off the process heap. pfGPrograms can be deleted with
pfDelete.
pfGetGProgramClassType returns the pfType* for the class pfGProgram. The
pfType* returned by pfGetGProgramClassType is the same as the pfType*
returned by invoking pfGetType 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 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 pfGProgram is a sequence of assembly-like instructions that are
Page 2
pfGProgram(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
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 methods pfGProgramProgram and pfGProgramProgramLen. In
the second method 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 pfGProgramLoadProgram.
You can apply the pfGProgram using pfGProgramApply, but only in the draw
process. Once the pfGProgram has been applied, you can query its state
using the following methods: pfGetGProgramProgramLength, which return
the number of instructions of the program,
pfGetGProgramNativeProgramLength, which returns the number of
instructions used by the specific GPU, and pfGProgramIsValid, 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