Context:
TYPE ~
RECORD [
class: REF ContextClass ← NIL,
stopMe: REF BOOLEAN ← NIL, -- stop flag for bailing out (ref for inheritance)
imageReady: BOOLEAN ← FALSE, -- flag for useable image in display
Scene description
frameNumber: NAT ← 0, -- current frame for animation routines
shapes: REF ShapeSequence ← NIL, -- current collection of shapes and lights
visibleShapes: REF ShapeSequence ← NIL, -- computed by SurfaceRender.ValidateContext
lightSources: REF ShapeSequence ← NIL, -- computed by SurfaceRender.ValidateContext
environment: Atom.PropList ← NIL, -- for reflection map, ambient light proc, etc.
View description
viewInValid: BOOLEAN ← TRUE, -- true whenever view parameter updated
eyePoint: Triple ← [1.0, -5.0, 2.0], -- defines point from which view is seen
ptOfInterest: Triple ← [0.,0.,0.], -- defines center of image and focus
rollAngle: REAL ← 0., -- rotational angle about direction of view
upDirection: Triple ← [0.,0.,1.], -- defines "heads-up" direction (redundant)
fieldOfView: REAL ← 40., -- horizontal angle included in field of view
window: REF Rectangle ← NIL, -- window clips field of view in eyespace
hitherLimit: REAL ← 1., -- anything closer to eyepoint is clipped
yonLimit: REAL ← 1000., -- anything further from eyepoint is clipped
clippingPlanes: ARRAY SixSides OF Quad, -- computed clip planes
eyeSpaceXfm: Xfm3D ← NIL, -- world space to eyespace
eyeToNdc: ScaleAndAddXfm ← [1.,1.,1., 0.,0.,0.], -- eyespace to normalized display coords
ndcToPixels: ScaleAndAddXfm ← [1.,1.,1., 0.,0.,0.], -- to screen coords
Display description
viewer: ViewerClasses.Viewer, -- viewer record if in Viewer ELSE NIL
terminal: Terminal.Virtual ← NIL, -- virtual terminal for this context, if displayed
displayInValid: BOOLEAN ← TRUE, -- true whenever display parameter updated
pixels: ImagerPixel.PixelMap ← NIL, -- where the bits are
pixelAspectRatio: REAL ← 1.0, -- physical width/height of displayed pixel
viewPort: REF Rectangle ← NIL, -- viewport in floating pt. display coordinates
preferredViewPort: Rectangle ← [0.,0.,65536.,65536.], -- maximum viewport size
extentCovered: Box ← [[0, 0], [0, 0]], -- bounds area used (while building image)
preferredRenderMode: ATOM ← NIL, -- $Pixels, $Imager (fancy vs. device independent)
displayProps: Atom.PropList ← NIL, -- $Depth, $Alpha (Pixel posn),
-- $FullDisplayMemory, $ViewerAdjusted
Rendering Style
autoRedraw: BOOLEAN ← FALSE, -- quick image hint, redraw if viewer changes
delayClear: BOOLEAN ← FALSE, -- delay clearing buffer when rendering
doVisibly: BOOLEAN ← TRUE, -- build image on display
antiAliasing: BOOLEAN ← FALSE, -- flag for antialiasing and alpha buffer
depthBuffering: BOOLEAN ← FALSE, -- buffer for cheap hidden-surface removal
depthResolution: NAT ← 8192, -- number of buckets for depth sorting
sortSequence: REF ← NIL, -- shapes or surfaces sorted for display
props: Atom.PropList ←
NIL
-- catchall
Global uses for context.props: - $WDir - working directory
- $Log - log file for messages
- $BackGround - background color or context (for images)
- $DitherContext - for dithering RGB to pseudocolor
- $OutputFile - output file for interpress or animation
- $ImagerCtx - context for Imager calls, when no viewer
- $SortToPriority - forces priority sort, poly intersections
];
ContextClass:
TYPE ~
RECORD[
displayType: ATOM ← NIL, -- { $PseudoColor, $Gray, $FullColor,
$ImagerGray, $ImagerDithered, $ImagerFullClr,
$Bitmap, $Interpress }
setUpDisplayType: ContextProc, -- makes sure there are bits to write, sets up colors
validateDisplay: ContextProc, -- makes sure viewPort changes, etc. take effect
render: ContextProc, -- call this to display the scene
loadBackground: ContextProc, -- clear to background
2d drawing primitives use normalized display coordinates (-1.0 < x < 1.0, -.75 < y < .75)
draw2DLine: PROC[context: REF Context, p1, p2: Pair, color: Pixel], -- display a line
draw2DPolygon: PROC[context: REF Context, poly: REF PairSequence, color: Pixel],
draw2DRope: PROC[context: REF Context, rope: Rope.ROPE, position: Pair,
color: Pixel ← [255,255,128,0,0], size: REAL ← 20, font: Rope.ROPE ← NIL],
displayPolygon: PatchProc, -- 3 dimensional shading
drawInViewer: PROC[ context: REF Context, procRec: REF ImagerProcRec ],
updateViewer: ContextProc
];