The viewportDraw() Function

If the drawable returns false from the worldDraw() callback, it invokes viewportDraw() once for each active viewport to allow the drawable to describe its viewport-specific display. AcGiViewportDraw and AcGiViewportGeometry are closely related to the worldDraw() equivalents, because they derive from the same base classes.

The viewportDraw() function works in a similar way as worldDraw(). The AcDbEntity::subViewportDraw() function takes a pointer to an AcGiViewportDraw object and builds the view-specific representation of an entity. The viewport draw object also provides access to other objects, which include the following:

The viewport geometry object provides the same list of primitives as the world geometry object and adds to it the following primitives, which use eye- and display-space coordinates to draw polylines and polygons:

The viewport subentity traits object is the same as that used by the world draw object (AcGiSubEntityTraits). The viewport object provides functions for querying the viewport's transformation matrices and viewing parameters.

Danger: A pointer to an AcGi object such as AcGiWorldDraw or AcGiViewportDraw should not be stored as a global or static variable. Do not save copies of pointers to AcGi objects across calls to worldDraw() and viewportDraw(). Once these functions return, the pointers are no longer valid.