pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAMEpfGProgramParms - class used to define parameters for GPU programs
FUNCTION SPECIFICATION
#include <Performer/pr/pfGProgram.h>
pfGProgramParms::pfGProgramParms();
pfType * pfGProgramParms::getClassType(void);
void pfGProgramParms::setParameters(int index, int type, int count,
void* ptr);
void pfGProgramParms::update();
int pfGProgramParms::getNumParameters(void);
void pfGProgramParms::getParameters(int i, int *ix, int *type,
int *count, void **v);
void pfGProgramParms::getParametersByIndex(int ix, int *type,
int *count, void **v);
int pfGProgramParms::getType();
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. 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 pfGProgramParms 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();
Page 1
pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
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 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.
new pfGProgramParms 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. 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
pfGeoState::setMultiAttr 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
Page 2
pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
index to the pfGeoState::setMultiAttr function call.
pfGProgram::getClassType returns the pfType* for the class
pfGProgramParms. The pfType* returned by pfGProgramParms::getClassType
is the same as the pfType* returned by invoking the virtual function
getType 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 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 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 pfGProgramParms::setParameters,
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 = new pfGProgramParms(PFGP_FRAGMENT_LOCAL, arena);
parms->setParameters(0, PF_GPP_FLOAT_4, 2, data);
geoState->setMultiAttr(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.
The number of existing parameters in a pfGProgramParms can be queried
using pfGProgramParms:getNumParameters. The parameters can be queried
either by the order they were specified using
pfGProgramParms:getParameters or by the index they are accessed, using
Page 3
pfGProgramParms(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
pfGProgramParms:getParametersByIndex.
You can apply the pfGProgramParms using pfGProgramParms::apply, but only
in the draw process. If a pfGProgramParms structure is modified after it
has been applied, pfGProgramParms::update 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