pfAlphaFunc(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAME
pfAlphaFunc, pfGetAlphaFunc - Specify alpha function and reference value
FUNCTION SPECIFICATION
#include <Performer/pr.h>
void pfAlphaFunc(float ref, int mode);
void pfGetAlphaFunc(float *ref, int *mode);
PARAMETERS
ref is a reference value with which to compare source alpha at each
pixel. This value should be a float in the range 0 through 1.
mode is a symbolic constant that specifies the conditional comparison
that source alpha and ref must pass for a pixel to be drawn.
DESCRIPTION
pfAlphaFunc sets the alpha function mode and reference value which
affects all subsequent geometry. mode is a symbolic constant that
specifies the conditional comparison that source alpha and ref must pass
for a pixel to be drawn. For example:
if (source alpha mode ref)
draw the pixel
where the alpha value boolean function mode is be one of:
PFAF_ALWAYS
PFAF_EQUAL
PFAF_GEQUAL
PFAF_GREATER
PFAF_LEQUAL
PFAF_LESS
PFAF_NEVER
PFAF_NOTEQUAL
PFAF_OFF
If it was desired to only draw pixels whose alpha value was greater than
or equal to 50% of the representable range, then a mode of PFAF_GEQUAL
and a ref of 0.5 would produce the hardware pixel rendering conditional:
if (source alpha PFAF_GEQUAL 0.5)
draw the pixel
The the default mode is PFAF_OFF and default ref value is 0. The alpha
function and reference value state elements are identified by the
PFSTATE_ALPHAFUNC mode and PFSTATE_ALPHAREF value tokens respectively.
Use these tokens with pfGeoState::setMode and pfGeoState::setVode,
respectively, to set the alpha function and reference value of a
Page 1
pfAlphaFunc(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
pfGeoState and with pfOverride to override subsequent alpha function and
reference value changes.
Here is an example:
/*
* Setup pfGeoState so that only pixels whose alpha is > 40
* are drawn once the pfGeoState is applied with pfGeoState::apply.
*/
gstate->setMode(PFSTATE_ALPHAFUNC, PFAF_GREATER);
gstate->setVal(PFSTATE_ALPHAREF, (40.0f/255.0f));
/*
* Override alpha function. The alpha reference value can still
* be changed.
*/
pfOverride(PFSTATE_ALPHAFUNC, PF_ON);
/*
* All subsequent attempts to set alpha function will be ignored
* until pfOverride is called to unlock it.
*/
pfAlphaFunc is a display-listable command. If a pfDispList has been
opened by pfDispList::open, pfAlphaFunc will not have immediate effect
but will be captured by the pfDispList and will only have effect when
that pfDispList is later drawn with pfDispList::draw.
pfGetAlphaFunc copies the current alpha function reference value and mode
into ref and mode respectively.
NOTES
pfAlphaFunc is typically used for textures with alpha that simulate trees
and other complicated geometry having many holes. See the OpenGL
glAlphaFunc manual page for further details.
SEE ALSO
afunction, glAlphaFunc, pfDispList, pfGeoState, pfState
Page 2