pfTransparency(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
NAME
pfTransparency, pfGetTransparency - Set/get the transparency mode
FUNCTION SPECIFICATION
#include <Performer/pr.h>
void pfTransparency(int type);
int pfGetTransparency(void);
PARAMETERS
type is a symbolic constant and is one of:
PFTR_OFF
Disable transparency
PFTR_ON
OpenGL Performer will use a default transparency mechanism
depending on the machine being used.
PFTR_HIGH_QUALITY
OpenGL Performer will use a transparency mechanism that
provides the highest quality, not necessarily the fastest,
transparency.
PFTR_FAST
OpenGL Performer will use a transparency mechanism that
provides the fastest, not necessarily the highest quality,
transparency.
PFTR_BLEND_ALPHA
OpenGL Performer will use the OpenGL glBlendFunc(3g) method of
transparency.
PFTR_MS_ALPHA
OpenGL Performer will use the the OpenGL
glEnable(GL_SAMPLE_ALPHA_TO_ONE_SGIS) method of transparency
when multisampling is available and enabled. Source alpha
values will be converted to 1.0 (full opacity) before writing
to the framebuffer.
PFTR_MS_ALPHA_MASK
OpenGL Performer will use the OpenGL
glEnable(GL_SAMPLE_ALPHA_TO_MASK_SGIS) method of transparency
when multisampling is enabled. Source alpha values will not be
modified.
type may be OR-ed with PFTR_NO_OCCLUDE if transparent geometry is not to
occlude other geometry.
Page 1
pfTransparency(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
DESCRIPTIONpfTransparency sets the transparency mode to mode. Enabling transparency
is not enough to render transparent geometry. Geometry colors must have
alpha values that are less than the maximum (alpha < 1 for c4f and alpha
< 255 for cpack) in order to be transparent. When alpha is less than
maximum, it defines the blending of geometry color with framebuffer color
according to the following equation.
finalColor = alpha * geometryColor + ( 1 - alpha ) *
colorInFramebuffer
In other words, alpha is the "inverse" of transparency.
The transparency mode value may be OR-ed with PFTR_NO_OCCLUDE.
PFTR_NO_OCCLUDE disables writes to the depth buffer so that any geometry
rendered after pfTransparency is called with this value will not modify
the depth buffer and so will not be able to occlude any other geometry.
Since you can "see-through" transparent geometry, this is a useful option
when using PFTR_BLEND_ALPHA type transparency and you are unable to
render transparent geometry back to front.
pfGetTransparency returns the current transparency mode.
The transparency mode state element is identified by the
PFSTATE_TRANSPARENCY token. Use this token with pfGeoState::setMode to
set the transparency mode of a pfGeoState and with pfOverride to override
subsequent transparency mode changes.:
Example 1:
/* Set up transparent pfGeoState */
gstate->setMode(PFSTATE_TRANSPARENCY, PFTR_HIGH_QUALITY);
/* Attach gstate to gset */
gset->setGState(gstate);
/*
* Draw transparent gset. 'gset' must have alpha values
* that are < 1.0f for transparency to have effect.
*/
gset->draw();
Example 2:
/* Override transparency mode to PFTR_OFF */
pfTransparency(PFTR_OFF);
pfOverride(PFSTATE_TRANSPARENCY, PF_ON);
Page 2
pfTransparency(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages
The MS_ALPHA transparency methods only work when the window is configured
for multisampling. In this case alpha values are converted to a
multisample mask, a "screen door" if you will, that allows the geometry
color to only partially influence each pixel. This kind of transparency
is most efficient when multisampling and has the important benefit of
*not* requiring sorting of transparent geometry. PFTR_BLEND_ALPHA on the
other hand actually blends the geometry color with what is already in the
framebuffer. Thus it requires the following for proper results:
1. Transparent geometry be rendered after opaque geometry.
2. Transparent geometry be rendered back to front.
pfTransparency is a display-listable command. If a pfDispList has been
opened by pfDispList::open, pfTransparency 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.
BUGSpfTransparency modifies the zwritemask but does not restore it.
SEE ALSO
blendfunction, msalpha, msmask, glEnable, glSampleMaskSGIS, pfDispList,
pfGeoState, pfState, zwritemask
Page 3