pfuStyle(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages pfuStyle(3pf)NAME
pfuPreDrawStyle, pfuPostDrawStyle - Functions to produce fancy drawing
styles.
FUNCTION SPECIFICATION
#include <Performer/pf.h>
#include <Performer/pfutil.h>
void pfuPreDrawStyle(int style, pfVec4 scribeColor);
void pfuPostDrawStyle(int style);
PARAMETERS
style identifies a drawing style.
DESCRIPTION
Both pfuPreDrawStyle and pfuPostDrawStyle use multi-pass rendering to
implement special draw styles that are not directly provided by the
hardware or graphics library. These effects, such as hidden line
rendering and haloed polygons, can however be achieved with high-
performance Z-buffered graphics rendering hardware as these functions
demonstrate.
pfuPreDrawStyle should be called in the Performer draw callback just
before pfDraw. pfuPostDrawStyle must then be called after pfDraw. These
two functions are a pair and both must be called as described.
The style argument can take the following values.
PFUSTYLE_POINTS
This causes polygon vertices to be drawn as small points. In
many cases, internal structural aspects can be observed from
the resulting "cloud of points" image, especially when that
image is in motion on the screen.
PFUSTYLE_LINES
This causes polygons to be drawn in wireframe mode using the
Performer PFGS_WIREFRAME draw style. The lines are drawn in the
same color as the base geometry.
PFUSTYLE_DASHED
This is a wireframe drawing style that does something slightly
tricky: it draws the front-facing polygons of an object in the
normal wireframe mode and the back-facing polygons in a dashed
line mode, creating a typical draftsman's dashed-occlusion hint
style of hidden line drawing.
PFUSTYLE_HALOED
Polygons are drawn in wireframe mode with haloed edges. This is
the drawing style of electronic schematics, where lines that
cross but are not connected have a slight gap or break in the
Page 1
pfuStyle(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages pfuStyle(3pf)
lower line. This same idea can be extended to 3D geometry, and
was proposed as a rendering mode by graphics pioneer Dr. Arthur
Appel.
PFUSTYLE_HIDDEN
Hidden polygons are not drawn while visible polygons are drawn
in wireframe mode. This is the traditional hidden-line removal
display mode.
PFUSTYLE_FILLED
Draws polygons as filled solids. This hidden-surface removal
display mode is the standard display style.
PFUSTYLE_SCRIBED
Polygons are drawn filled with hidden surfaces removed. The
boundary of each visible polygon is highlighted in a wire frame
highlight. This mode can be very useful in understanding the
geometric complexity of textured scenes.
When style takes the values PFUSTYLE_POINTS or PFUSTYLE_DASHED,
pfuPostDrawStyle restores polygon drawing to the normal filled mode.
Finally, for every value of style, it restores the state before
pfuPreDrawStyle was called.
The scribeColor argument is the desired color for scribed lines. The
first three elements of the array represent the red, green, and blue
values in the range 0 to 1, and the final element is the alpha value for
the scribed lines. This argument is not used in the other style modes.
The following code fragment displays how pfuPreDrawStyle and
pfuPostDrawStyle would typically be used in an application. See the
files:
/usr/share/Performer/src/sample/C/perfly.c
/usr/share/Performer/src/sample/C++/perfly.C
for details.
Example 1:
/* convey draw style from localPreDraw to localPostDraw */
static int selectedDrawStyle = 0;
void
localPreDraw(pfChannel *chan, void *data)
{
:
:
/*
* remember draw style in case it changes between now
* and the time localPostDraw() gets called.
Page 2
pfuStyle(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages pfuStyle(3pf)
*/
selectedDrawStyle = ViewState->drawStyle;
/* handle draw style */
pfuPreDrawStyle(selectedDrawStyle, ViewState->drawColor);
}
void
localPostDraw(pfChannel *chan, void *data)
{
/* handle draw style */
pfuPostDrawStyle(selectedDrawStyle);
:
:
}
SEE ALSO
pfDraw
Page 3