pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
NAME
pfNewLModel, pfGetLModelClassType, pfApplyLModel, pfLModelAtten,
pfGetLModelAtten, pfLModelLocal, pfGetLModelLocal, pfLModelTwoSide,
pfGetLModelTwoSide, pfLModelAmbient, pfGetLModelAmbient, pfGetCurLModel -
Create, modify and query lighting model
FUNCTION SPECIFICATION
#include <Performer/pr.h>
pfLightModel * pfNewLModel(void *arena);
pfType * pfGetLModelClassType(void);
void pfApplyLModel(pfLightModel *lm);
void pfLModelAtten(pfLightModel *lm, float a0, float a1,
float a2);
void pfGetLModelAtten(const pfLightModel *lm, float *a0,
float *a1, float *a2);
void pfLModelLocal(pfLightModel *lm, int l);
int pfGetLModelLocal(const pfLightModel *lm);
void pfLModelTwoSide(pfLightModel *lm, int t);
int pfGetLModelTwoSide(const pfLightModel *lm);
void pfLModelAmbient(pfLightModel *lm, float r, float g,
float b);
void pfGetLModelAmbient(const pfLightModel *lm, float *r,
float *g, float *b);
pfLightModel * pfGetCurLModel(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfLightModel is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfLightModel. Casting an object of
class pfLightModel 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);
Page 1
pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
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 pfLightModel 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
lm identifies a pfLightModel.
DESCRIPTION
A pfLightModel defines characteristics of the hardware lighting model
used to illuminate geometry. See the OpenGL glLightModel(3g) man page
for more details on lighting environments and individual parameters.
pfNewLModel creates and returns a handle to a pfLightModel. arena
specifies a malloc arena out of which the pfLightModel is allocated or
NULL for allocation off the process heap. A NULL pointer is returned to
indicate failure. pfLightModels can be deleted with pfDelete.
pfGetLModelClassType returns the pfType* for the class pfLightModel. The
pfType* returned by pfGetLModelClassType is the same as the pfType*
returned by invoking pfGetType on any instance of class pfLightModel.
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.
pfLModelAtten sets the lighting attenuation factors for lm. a1, a2, and
a3 specify the constant, linear, and second-order attenuation factors,
respectively. These factors are associated with all non-infinite lights.
Page 2
pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
The default values for constant, linear, and quadratic attenuation
factors are 1.0, 0.0, and 0.0, respectively, effectively disabling each.
Note that OpenGL light attenuation is done per-light. See the
pfLightAtten man page for more information.
pfGetLModelAtten copies the lighting attenuation factors for lm into the
parameters a1, a2, and a3.
pfLModelLocal specifies whether the light reflection calculations are to
be done based on a local or infinite viewpoint. The default is PF_OFF
signifying an infinite viewer for the light model. In general, local
lighting is more expensive than infinite lighting.
pfGetLModelLocal returns a boolean value signifying whether or not the
effective viewpoint in lm is a local viewpoint.
pfLModelTwoSide specifies whether two-sided lighting is to be used in the
given light model. The default is PF_OFF, disabling two-sided lighting.
See the OpenGL glLightModel man page for more details on two-sided
lighting.
pfGetLModelTwoSide returns the setting of lm's two-sided lighting mode.
pfLModelAmbient receives three floating point values in the range from
0.0 through 1.0 to set the red, green, and blue, values for the amount of
the ambient light associated with the scene for the given light model.
pfGetLModelAmbient copies the red, green, and blue components of the
ambient in the given light model into the parameters r, g, and b,
respectively. The default value for the ambient red, green, and blue
light components is 0.2.
pfApplyLModel causes lm, with its current settings, to become the current
lighting model. When lighting is enabled (See below), this lighting
model will be applied to all geometry drawn after pfApplyLModel is
called. Modifications to lm, such as changing the ambient color, or
setting two-sided lighting, will not be applied until pfApplyLModel is
called with lm.
For geometry to be illuminated, the following must be true:
1. Lighting must be enabled: pfEnable(PFEN_LIGHTING)
2. A pfLightModel must be applied: pfApplyLModel
3. A pfMaterial must be applied: pfApplyMtl
4. One or more pfLights must be on: pfLightOn
5. Illuminated geometry must have normals: pfGSetAttr,
PFGS_NORMAL3
Page 3
pfLightModel(3pf) OpenGL Performer 3.2.2 libpr C Reference Pages
The lighting model state element is identified by the PFSTATE_LIGHTMODEL
token. Use this token with pfGStateAttr to set the lighting model of a
pfGeoState and with pfOverride to override subsequent lighting model
changes:
EXAMPLES
Example 1:
pfLModelTwoSide(lmodel, PF_ON);
/* Set up two-sided lighting pfGeoState */
pfGStateMode(gstate, PFSTATE_ENLIGHTING, PF_ON);
pfGStateAttr(gstate, PFSTATE_LIGHTMODEL, lmodel);
pfGStateAttr(gstate, PFSTATE_FRONTMTL, mtl);
pfGStateAttr(gstate, PFSTATE_BACKMTL, mtl);
pfGStateMode(gstate, PFSTATE_CULLFACE, PF_OFF);
/* Attach gstate to gset */
pfGSetGState(gset, gstate);
/* Set normal array. 'gset' is non-indexed */
pfGSetAttr(gset, PFGS_NORMAL3, PFGS_PER_VERTEX, norms, NULL);
/* Draw lit, two-sided gset */
pfDrawGSet(gset);
Example 2:
pfApplyLModel(lmodel);
/* Override so that all geometry is lit with 'lmodel' */
pfOverride(PFSTATE_LIGHTMODEL, PF_ON);
pfApplyLModel is a display-listable command. If a pfDispList has been
opened by pfOpenDList, pfApplyLModel will not have immediate effect but
will be captured by the pfDispList and will only have effect when that
pfDispList is later drawn with pfDrawDList.
pfGetCurLModel returns a pointer to the currently active pfLightModel, or
NULL if there is no active pfLightModel.
SEE ALSO
pfDelete, pfDispList, pfGeoState, pfLight, glLightModel, pfMaterial,
pfObject, pfState, lmbind, lmcolor, lmdef
Page 4