Software Pipeline li1DisplayGcache
D
- The following code from the software pipeline 3D li1DisplayGcache() function illustrates the sequence of events in rendering for each of the 3D Gcache primitive types. You can copy or modify this source code sample as long as the resulting code is used to create a loadable pipeline for XGL.
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
Xgl_cache_display
XglSwpCtx3dDef::li1DisplayGcache(Xgl_gcache gcache_obj,
Xgl_boolean test,
Xgl_boolean display,
Xgl_booleando_retained)
{
XglGcache* gcache;
XglGcachePrim* prim;
Xgl_cache_display ret_val;
Xgl_boolean do_display;
Xgl_usgn32 num_model_clip_planes;
gcache = (XglGcache*) gcache_obj;
prim = gcache->getGcachePrim();
if (prim == NULL) {
return (XGL_CACHE_NOT_CHECKED);
}
if ((prim->getDisplayPrimType() != XGL_PRIM_NONE) &&
!prim->getSavedCtxIs3d() ) {
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
return(XGL_CACHE_NOT_CHECKED); /* ctx dims don't match;
best fit */
}
if (test) {
if ((prim->getDisplayPrimType() != XGL_PRIM_NONE) &&
(prim->validate(ctx))) {
do_display = display;
ret_val = XGL_CACHE_DISPLAY_OK;
}
else {
do_display = FALSE;
ret_val = XGL_CACHE_ATTR_STATE_DIFFERENT;
}
}
else {
do_display = display;
ret_val = XGL_CACHE_NOT_CHECKED;
}
if ((prim->getDisplayPrimType() == XGL_PRIM_NONE) ||
!do_display)
return ret_val;
if (prim->wasModelClipped() &&
((ret_val == XGL_CACHE_DISPLAY_OK) ||
gcache->getBypassModelClip())) {
num_model_clip_planes = ctx->getModelClipPlaneNum();
xgl_object_set(ctx, XGL_3D_CTX_MODEL_CLIP_PLANE_NUM, 0, 0);
}
else
num_model_clip_planes = 0;
switch (gcache->getOrigPrimType()) {
case XGL_PRIM_STROKE_TEXT:
{
XglGcachePrimText*gp_text = (XglGcachePrimText *)
gcache->getGcachePrim();
Xgl_geom_status status;
if (gp_text->getDisplayPtListList()->num_pt_lists < 1)
return ret_val;
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
xgl_context_check_bbox(ctx,XGL_PRIM_MULTIPOLYLINE,
gp_text->getPlm()->get_pll_bbox(),&status);
if ((status & XGL_GEOM_STATUS_VIEW_REJECT) ||
(status & XGL_GEOM_STATUS_MODEL_REJECT)) return ret_val;
XGLI_3D_DP(void, XGLI_LI1_MULTIPOLYLINE,
(Xgl_bbox*,Xgl_usgn32,Xgl_pt_list*, Xgl_boolean),
(NULL, gp_text->getDisplayPtListList()->num_pt_lists,
gp_text->getDisplayPtListList()->pt_lists, FALSE))
}
break;
case XGL_PRIM_NURBS_SURFACE:
{
XglGcachePrimNSurf* gp_nsurf = (XglGcachePrimNSurf*)
gcache->getGcachePrim();
void* cache_data = gp_nsurf->getCacheData();
if(cache_data == NULL){
XglNurbsSurfData* apiData = gp_nsurf->getApiData();
if(apiData->surface->order_u == 1 ||
apiData->surface->order_v == 1) {
Xgl_pt_list plist;
plist.pt_type = apiData->surface->ctrl_pts.pt_type;
plist.num_pts = apiData->surface->ctrl_pts.num_pts;
plist.bbox = NULL;
plist.pts.f3d = apiData->surface->ctrl_pts.pts.f3d;
ctx->assignCurStrokeAsMarker();
XGLI_3D_DP(void, XGLI_LI1_MULTIMARKER,
(Xgl_pt_list*, Xgl_boolean),
(&plist, FALSE))
ctx->assignCurStrokeAsLine();
break;
}
else {
XglSwpNurbs nurbs(ctx, viewGrpItf, TRUE);
cache_data = nurbs.setUsrData(gp_nsurf->getApiData(),
gp_nsurf->getGcacheMode(), TRUE);
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
gp_nsurf->setCacheData(cache_data);
}
}
XGLI_3D_DP(void, XGLI_LI1_NURBS_SURFACE,
(Xgl_nurbs_surf*, Xgl_trim_loop_list*,
Xgl_nurbs_surf_simple_geom*,
Xgl_surf_color_spline*,
Xgl_surf_data_spline_list*, void*,
Xgl_boolean),
(NULL, NULL, NULL, NULL, NULL,
cache_data, FALSE))
}
break;
case XGL_PRIM_NURBS_CURVE:
{
XglGcachePrimNCurve*gp_ncurve =
(XglGcachePrimNCurve *)gcache->getGcachePrim();
void* cache_data = gp_ncurve->getCacheData();
if(cache_data == NULL){
XglNurbsCurveData* apiData =
gp_ncurve->getApiData();
if(apiData->curve->order == 1) {
Xgl_pt_list plist;
plist.pt_type = apiData->curve->ctrl_pts.pt_type;
plist.num_pts = apiData->curve->ctrl_pts.num_pts;
plist.bbox = NULL;
plist.pts.f3d = apiData->curve->ctrl_pts.pts.f3d;
ctx->assignCurStrokeAsMarker();
XGLI_3D_DP(void, XGLI_LI1_MULTIMARKER,
(Xgl_pt_list*, Xgl_boolean),
(&plist, FALSE))
ctx->assignCurStrokeAsLine();
break;
}
else {
XglSwpNurbs nurbs(ctx, viewGrpItf, TRUE);
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
cache_data = nurbs.setUsrData(gp_ncurve->getApiData(),
gp_ncurve->getGcacheMode(), TRUE);
gp_ncurve->setCacheData(cache_data);
}
}
ctx->assignCurStrokeAsLine();
XGLI_3D_DP(void, XGLI_LI1_NURBS_CURVE,
(Xgl_nurbs_curve*, Xgl_bounds_f1d*,
Xgl_curve_color_spline*, void*,
Xgl_boolean),
(NULL, NULL, NULL, cache_data, FALSE))
}
break;
case XGL_PRIM_TRIANGLE_LIST:
{
XglGcachePrimTlist* gp_tlist = (XglGcachePrimTlist*)
gcache->getGcachePrim();
register int i;
register Xgl_pt_list_list* display_pll =
gp_tlist->getDisplayPtListList();
register Xgl_facet_list_list* display_fll =
gp_tlist->getDisplayFacetListList();
register Xgl_tlist_flags display_tlflags =
gp_tlist->getDisplayTlistFlags();
for (i = 0; i < display_pll->num_pt_lists; i++) {
XGLI_3D_DP(void, XGLI_LI1_TRIANGLE_LIST,
(Xgl_facet_list*, Xgl_pt_list*,
Xgl_tlist_flags, Xgl_boolean),
(NULL, &(display_pll->pt_lists[i]),
display_tlflags, FALSE))
}
}
break;
case XGL_PRIM_TRIANGLE_STRIP:
{
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
XglGcachePrimTstrip*gp_tstrip =
(XglGcachePrimTstrip*)gcache->getGcachePrim();
register int i;
register Xgl_pt_list_list* display_pll =
gp_tstrip->getDisplayPtListList();
register Xgl_facet_list_list*display_fll =
gp_tstrip->getDisplayFacetListList();
for (i = 0; i < display_fll->num_facet_lists; i++) {
XGLI_3D_DP(void, XGLI_LI1_TRIANGLE_STRIP,
(Xgl_facet_list*, Xgl_pt_list*, Xgl_boolean),
(&(display_fll->facet_lists[i]),
&(display_pll->pt_lists[i]), FALSE))
}
}
break;
case XGL_PRIM_POLYGON:
{
Xgl_boolean do_orig_pgon;
Xgl_boolean edges;
XglGcachePrimPgon* gp_pgon = (XglGcachePrimPgon*)
gcache->getGcachePrim();
do_orig_pgon = FALSE;
if ((gcache->getDisplayPrimType() ==
XGL_PRIM_MULTI_SIMPLE_POLYGON) &&
(gcache->getDoPolygonDecomp())) {
/* The pgon has been decomposed into a list
of triangle stars */
Xgl_surf_fill_style fill_style;
Xgl_pt_list_list* decomp_pll;
Xgl_pt_list_list* display_pll;
Xgl_facet_list* decomp_fl;
Xgl_boolean front_facing = TRUE;
Xgl_pt_f3d* normal;
Xgl_boolean do_silhouette = FALSE;
Xgl_boolean use_front_attributes,
use_back_attributes;
Xgl_surf_fill_style front_style;
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
Xgl_surf_fill_style back_style;
Xgl_boolean distinguish;
Xgl_surf_cull_mode cull_mode;
decomp_pll = gp_pgon->getDecompPtListList();
display_pll = gp_pgon->getDisplayPtListList();
decomp_fl = gp_pgon->getDecompFacetList();
front_style = ctx->getSurfFrontFillStyle();
back_style = ctx->getSurfBackFillStyle();
cull_mode = ctx->getSurfFaceCull();
distinguish = ctx->getSurfFaceDistinguish();
/* find out what attributes will be used */
if (distinguish) {
switch (cull_mode) {
case XGL_CULL_OFF:
use_front_attributes = TRUE;
use_back_attributes = TRUE;
break;
case XGL_CULL_BACK:
use_front_attributes = TRUE;
use_back_attributes = FALSE;
break;
case XGL_CULL_FRONT:
use_front_attributes = FALSE;
use_back_attributes = TRUE;
break;
}
}
else {
use_front_attributes = TRUE;
use_back_attributes = FALSE;
}
if (use_front_attributes)
fill_style = front_style;
else
fill_style = back_style;
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
/* see if orig pgon data must be used to */
/* avoid seeing the tessalation */
if (distinguish) {
if (cull_mode == XGL_CULL_FRONT &&
back_style == XGL_SURF_FILL_HOLLOW)
do_orig_pgon = TRUE;
else if (cull_mode == XGL_CULL_BACK &&
front_style == XGL_SURF_FILL_HOLLOW)
do_orig_pgon = TRUE;
}
else if (front_style == XGL_SURF_FILL_HOLLOW)
do_orig_pgon = TRUE;
/* see if we need to determine the pgon */
/* facing */
if (!do_orig_pgon &&
use_front_attributes && use_back_attributes &&
front_style != back_style &&
(front_style == XGL_SURF_FILL_HOLLOW ||
back_style == XGL_SURF_FILL_HOLLOW)) {
/* determine if pgon is front or back facing */
switch (decomp_fl->facet_type) {
case XGL_FACET_NORMAL:
normal = &(decomp_fl->facets.normal_facets->normal);
break;
case XGL_FACET_COLOR_NORMAL:
normal = &(decomp_fl->facets.
color_normal_facets->normal);
break;
}
/* if culled were done */
front_facing = (XgliUtFaceDistinguish(ctx, normal,
display_pll->pt_lists->pts.f3d, viewGrpItf) ==
ctx->getSurfFrontAttr3d());
if (front_facing && (cull_mode == XGL_CULL_FRONT))
return ret_val;
if (!front_facing && (cull_mode == XGL_CULL_BACK))
return ret_val ;
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
if (front_facing)
fill_style = front_style;
else
fill_style = back_style;
}
do_silhouette = ctx->getSurfSilhouetteEdgeFlag();
if (!gcache->getShowDecompEdges() &&
!(do_silhouette &&
fill_style == XGL_SURF_FILL_EMPTY &&
ctx->getSurfEdgeFlag() == FALSE) &&
fill_style == XGL_SURF_FILL_HOLLOW)
do_orig_pgon = TRUE;
if (!do_orig_pgon) {
if (gp_pgon->getPgonConvex()) {
XGLI_3D_DP(void, XGLI_LI1_MULTI_SIMPLE_POLYGON,
(Xgl_facet_flags, Xgl_facet_list*,
Xgl_bbox*,
Xgl_usgn32, Xgl_pt_list*,
Xgl_boolean),
(gp_pgon->getMspgFlags(), decomp_fl,
display_pll->bbox, 1,
display_pll->pt_lists, FALSE))
}
else {
edges = ctx->getSurfEdgeFlag();
if (edges && !gcache->getShowDecompEdges())
xgl_object_set(ctx, XGL_CTX_SURF_EDGE_FLAG,
FALSE, 0);
/* pgon was decomposed into an msp list */
decomp_pll = gp_pgon->getDecompPtListList();
if(decomp_pll->num_pt_lists){
XGLI_3D_DP(void, XGLI_LI1_MULTI_SIMPLE_POLYGON,
(Xgl_facet_flags, Xgl_facet_list*,
Xgl_bbox*, Xgl_usgn32, Xgl_pt_list*,
Xgl_boolean),
(gp_pgon->getMspgFlags(),
gp_pgon->getDisplayFacetListList()
->facet_lists,
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
decomp_pll->bbox,
decomp_pll->num_pt_lists,
decomp_pll->pt_lists,
FALSE))
}
}
/* turn edges on and render orig polygon as empty */
if (edges && !gcache->getShowDecompEdges()
&& !gp_pgon->getPgonConvex()) {
xgl_object_set(ctx, XGL_CTX_SURF_EDGE_FLAG,
TRUE, 0);
if (front_facing)
xgl_object_set(ctx,
XGL_CTX_SURF_FRONT_FILL_STYLE,
XGL_SURF_FILL_EMPTY,
0);
else
xgl_object_set(ctx,
XGL_3D_CTX_SURF_BACK_FILL_STYLE,
XGL_SURF_FILL_EMPTY,
0);
Xgl_pt_list_list* pgon_pll =
gp_pgon->getPgonPtListList();
if (pgon_pll->num_pt_lists == 0) {
return ret_val;
}
if(pgon_pll->num_pt_lists){
XGLI_3D_DP(void, XGLI_LI1_POLYGON,
(Xgl_facet_type, Xgl_facet*,
Xgl_bbox*, Xgl_usgn32,
Xgl_pt_list*, Xgl_boolean),
(gp_pgon->getPgonFacetType(),
gp_pgon->getPgonFacetPtr(),
pgon_pll->bbox,
pgon_pll->num_pt_lists,
pgon_pll->pt_lists, FALSE))
}
/* restore fill style */
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
if (front_facing)
xgl_object_set(ctx,
XGL_CTX_SURF_FRONT_FILL_STYLE, fill_style,
0);
else
xgl_object_set(ctx,
XGL_3D_CTX_SURF_BACK_FILL_STYLE,
fill_style,
0);
}
}
}
if (gcache->getDisplayPrimType() == XGL_PRIM_POLYGON ||
do_orig_pgon) {
if (gcache->getUseApplGeom()) {
Xgl_pt_list_list* appl_pll =
gp_pgon->getApplPtListList();
if(appl_pll->num_pt_lists == 0)
return ret_val;
XGLI_3D_DP(void, XGLI_LI1_POLYGON,
(Xgl_facet_type, Xgl_facet*,
Xgl_bbox*, Xgl_usgn32,
Xgl_pt_list*, Xgl_boolean),
(gp_pgon->getPgonFacetType(),
gp_pgon->getPgonFacetPtr(),
appl_pll->bbox,
appl_pll->num_pt_lists,
appl_pll->pt_lists, FALSE))
}
else {
Xgl_pt_list_list*pgon_pll =
gp_pgon->getPgonPtListList();
if (pgon_pll->num_pt_lists == 0) {
return ret_val;
}
XGLI_3D_DP(void, XGLI_LI1_POLYGON,
(Xgl_facet_type, Xgl_facet*,
Xgl_bbox*, Xgl_usgn32,
Xgl_pt_list*, Xgl_boolean),
(gp_pgon->getPgonFacetType(),
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
gp_pgon->getPgonFacetPtr(),
pgon_pll->bbox,
pgon_pll->num_pt_lists,
pgon_pll->pt_lists, FALSE))
}
}
}
break;
case XGL_PRIM_ELLIPTICAL_ARC:
{
XglGcachePrimMella* gp_mella =
(XglGcachePrimMella *)gcache->getGcachePrim();
if(gp_mella->getDisplayPtListList()->num_pt_lists < 1)
return ret_val;
if (gcache->getDisplayPrimType() ==
XGL_PRIM_MULTIPOLYLINE) {
XGLI_3D_DP(void, XGLI_LI1_MULTIPOLYLINE,
(Xgl_bbox*,Xgl_usgn32,
Xgl_pt_list*, Xgl_boolean),
(NULL, gp_mella->getDisplayPtListList()
->num_pt_lists,
gp_mella->getDisplayPtListList()->pt_lists,
FALSE))
}
else if (gcache->getDisplayPrimType() ==
XGL_PRIM_MULTI_SIMPLE_POLYGON) {
XGLI_3D_DP(void, XGLI_LI1_MULTI_SIMPLE_POLYGON,
(Xgl_facet_flags, Xgl_facet_list*,
Xgl_bbox*, Xgl_usgn32,
Xgl_pt_list*, Xgl_boolean),
(XGL_FACET_FLAG_SHAPE_CONVEX,
gp_mella->getDisplayFacetListList()->facet_lists,
NULL,
gp_mella->getDisplayPtListList()->num_pt_lists,
gp_mella->getDisplayPtListList()->pt_lists,
FALSE))
}
}
break;
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
case XGL_PRIM_MULTI_SIMPLE_POLYGON:
{
Xgl_boolean do_orig_pgon;
Xgl_boolean edges;
XglGcachePrimMspg*gp_mspg = (XglGcachePrimMspg *)
gcache->getGcachePrim();
Xgl_pt_list_list* pll;
Xgl_facet_list_list* fll;
Xgl_usgn32 mspg_flags;
Xgl_usgn32 npl;
do_orig_pgon = FALSE;
edges = ctx->getSurfEdgeFlag();
Xgl_surf_fill_style front_style;
Xgl_surf_fill_style back_style;
Xgl_boolean distinguish;
Xgl_surf_cull_mode cull_mode;
front_style = ctx->getSurfFrontFillStyle();
back_style = ctx->getSurfBackFillStyle();
cull_mode = ctx->getSurfFaceCull();
distinguish = ctx->getSurfFaceDistinguish();
if (!distinguish && front_style == XGL_SURF_FILL_HOLLOW)
do_orig_pgon = TRUE;
else if (cull_mode == XGL_CULL_OFF &&
(front_style == XGL_SURF_FILL_HOLLOW ||
(back_style == XGL_SURF_FILL_HOLLOW && distinguish)))
do_orig_pgon = TRUE;
else if (cull_mode == XGL_CULL_FRONT &&
(distinguish && back_style == XGL_SURF_FILL_HOLLOW))
do_orig_pgon = TRUE;
else if (cull_mode == XGL_CULL_BACK &&
front_style == XGL_SURF_FILL_HOLLOW)
do_orig_pgon = TRUE;
if (do_orig_pgon || edges) {
if (gcache->getUseApplGeom()) {
if(npl = gp_mspg->getApplPtListList()
->num_pt_lists) {
mspg_flags = gp_mspg->getApplMspgFlags();
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
pll = gp_mspg->getApplPtListList();
fll = gp_mspg->getApplFacetListList();
}
}
else {
if(npl = gp_mspg->getDisplayPtListList()
->num_pt_lists) {
mspg_flags = gp_mspg->getApplMspgFlags();
pll = gp_mspg->getDisplayPtListList();
fll = gp_mspg->getDisplayFacetListList();
}
}
}
else {
if(npl = gp_mspg->getDisplayPtListList()->num_pt_lists)
{
mspg_flags = gp_mspg->getMspgFlags();
pll = gp_mspg->getDisplayPtListList();
fll = gp_mspg->getDisplayFacetListList();
}
}
if(npl) {
XGLI_3D_DP(void, XGLI_LI1_MULTI_SIMPLE_POLYGON,
(Xgl_facet_flags, Xgl_facet_list*, Xgl_bbox*,
Xgl_usgn32, Xgl_pt_list*,
Xgl_boolean),
(mspg_flags, fll->facet_lists, NULL, npl,
pll->pt_lists, FALSE))
}
}
break;
case XGL_PRIM_MULTIMARKER:
{
XglGcachePrimMarker*gp_marker =
(XglGcachePrimMarker *)gcache->getGcachePrim();
Xgl_pt_list_list* pll = gp_marker->getDisplayPtListList();
if (pll->num_pt_lists < 1)
return ret_val;
XGLI_3D_DP(void, XGLI_LI1_MULTIMARKER,
|
-
Code Example D-1 Software Pipeline 3D li1DisplayGcache
-
(Xgl_pt_list*, Xgl_boolean),
(pll->pt_lists, FALSE))
}
break;
case XGL_PRIM_MULTIPOLYLINE:
{
XglGcachePrimMpline*gp_mpline =
(XglGcachePrimMpline *)gcache->getGcachePrim();
Xgl_pt_list_list* pll = gp_mpline->getDisplayPtListList();
if (pll->num_pt_lists < 1)
return ret_val;
XGLI_3D_DP(void, XGLI_LI1_MULTIPOLYLINE,
(Xgl_bbox*,Xgl_usgn32,Xgl_pt_list*, Xgl_boolean),
(NULL, pll->num_pt_lists, pll->pt_lists, FALSE))
}
default:
break;
} /* end switch */
if (num_model_clip_planes > 0)
xgl_object_set(ctx, XGL_3D_CTX_MODEL_CLIP_PLANE_NUM,
num_model_clip_planes, 0);
return ret_val;
}
|
|