pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
NAME
pfNewGPParams, pfGetGPParamsClassType, pfGPParamsApply,
pfGPParamsParameters, pfGPParamsUpdate, pfGetGPParamsNumParameters,
pfGetGPParamsParameters, pfGetGPParamsParametersByIndex,
pfGetGPParamsType - class used to define parameters for GPU programs
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfGProgramParms* pfNewGPParams(int ptype, void *arena);
pfType* pfGetGPParamsClassType(void);
void pfGPParamsApply(pfGProgramParms* gpparams);
void pfGPParamsParameters(pfGProgramParms* gpparams,
int index, int type, int count, void* ptr);
void pfGPParamsUpdate(pfGProgramParms* gpparams);
int pfGetGPParamsNumParameters(pfGProgramParms* gpparams);
void pfGetGPParamsParameters(pfGProgramParms* gpparams,
int i, int *ix, int *type, int *count, void **v);
void -
pfGetGPParamsParametersByIndex(pfGProgramParms* gpparams,
int ix, int *type, int *count, void **v);
int pfGetGPParamsType(pfGProgramParms* gpparams);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfGProgramParms is derived from the parent
class pfObject, so each of these member functions of class pfObject are
also directly usable with objects of class pfGProgramParms. Casting an
object of class pfGProgramParms 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
pfGProgramParms(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 pfGProgramParms 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
gpparams identifies a pfGProgramParms
DESCRIPTION
The pfGProgramParms is a class that is used to store parameters of GPU
programs, specifically of pfVertexPrograms and pfFragmentPrograms.
Vertex programs are used by the GPU to transform vertices into normalized
device coordinates, and can perform various other calculations to
influence the values input to fragment programs. Fragment programs are
used to compute the color and depth value of each fragment as it is being
rendered. pfGProgramParms are used to set parameters that can be used by
vertex or fragment programs.
pfNewGProgramParms creates and returns a handle to a pfGProgramParms.
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. The ptype parameter to the constructor is one of
PFGP_FRAGMENT_LOCAL
local parameters of a single fragment program.
PFGP_FRAGMENT_ENV
environment parameters. Shared between all fragment programs.
PFGP_VERTEX_LOCAL
environment parameters of a single vertex program.
PFGP_VERTEX_ENV
environment parameters. Shared between all vertex programs.
Additionally, these type tokens are used as the index parameter to the
Page 2
pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
pfGStateMultiAttr function to identify which set of program parameters
are being set. That is, for each type of parameters (of those listed
above) needed, a single pfGProgramParms object can be created, with all
needed parameters of that type. Each of these objects can then be added
to a pfGeoState, if desired, where the type of the object is the index to
the pfGStateMultiAttr function call.
pfGetGProgramClassType returns the pfType* for the class pfGProgramParms.
The pfType* returned by pfGetGProgramParamsClassType is the same as the
pfType* returned by invoking pfGetType on any instance of class
pfGProgramParms. 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 pfGProgramParms is a set of indexed quadruples of floating point
values, that are used as parameters for vertex and fragment programs.
The values are specified using function pfGPParamsParameters, The index
specifies the first index of the specified parameters (the index by which
the parameters are accessed in the GPU program) and the count specifies
how many indices will be set. The type argument indicates the data type
of the parameter, and currently must be PF_GPP_FLOAT_4, indicating that
data is count vectors of 4 floats. The ptr argument is a pointer to the
data.
For example, the following code:
pfGeoState *geoState;
pfGProgramParms *parms;
float data[8];
/* Compute data... */
parms = pfNewGProgramParms(PFGP_FRAGMENT_LOCAL, arena);
pfGPParamsParameters(parms, 0, PF_GPP_FLOAT_4, 2, data);
pfGStateMultiAttr(geoState, PFGP_FRAGMENT_LOCAL, parms);
sets up some 8 value data as a local variable, accessible in indices 0
and 1 of a fragment program, and sets to the correct location of the
pfGeoState.
The data will be copied, so the pointer can be discarded, and needn't be
in shared memory. Setting a parameter with the same index as a previous
parameter will overwrite the previous (i.e., two different parameters of
type PFGP_VERTEX_ENV cannot both have index 2), but parameters with
different types may share the same indices. The number of parameters
used (and index maximums) are system specific limits.
Page 3
pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
The number of existing parameters in a pfGProgramParms can be queried
using pfGetGPParamsNumParameters. The parameters can be queried either
by the order they were specified using pfGetGPParamsParameters or by the
index they are accessed, using pfGetGPParamsParametersBy Index.
You can apply the pfGProgramParms using pfGProgramParamsApply, but only
in the draw process. If a pfGProgramParms structure is modified after it
has been applied, pfGProgramParamsUpdate will need to be called for the
change to take effect.
See the man pages for pfVertexProgram, pfFragmentProgram, and pfGProgram
and the sample code in
/usr/share/Performer/src/pguide/libpf/C++/gprogram.C.
SEE ALSO
pfGProgram, pfVertexProgram, pfFragmentProgram, pfObject.
Page 4