Create:
PUBLIC
PROC []
RETURNS [Context] ~ {
context: Context ← NEW[ContextRep];
wDir: ROPE ← Commander.PrependWorkingDir[" "]; -- add needed space (wierdness)
wDir ← Rope.Substr[base: wDir, len: Rope.Length[wDir] - 1]; -- drop space
context.props ← PutProp[context.props, $WDir, wDir]; -- keep directory
context.eyeSpaceXfm ← G3dMatrix.Identity[]; -- can't do this in initialization, so do it here
context.stopMe ← NEW[BOOLEAN ← FALSE];
RETURN[context];
};
InitializeRawColorDisplayContext:
PUBLIC
PROC [
antiAliasing: BOOL ← TRUE,
background: RGB ← [0.2, 0.2, 0.7],
displayMode: DisplayMode ← gray]
RETURNS [context: Context]
~ {
context ← Create[];
context.preferredRenderMode ← $Pixels;
LoadDisplayClass[context, AtomFromDisplayMode[displayMode]];
G3dRenderWithPixels.BufferRendering[context, FALSE]; -- , displayType = $FullColor];
SetAntiAliasing[context, antiAliasing];
SetBackgroundColor[context, background];
AddLight[context, "Light0", [-100.0, -200.0, 20.0]];
SetView[context, [3.0, -10.0, 3.0], []];
};
CopyContextData:
PUBLIC
PROC [dstCtx, srcCtx:
REF Context] ~ {
dstCtx.class ← IF srcCtx.class # NIL THEN NEW[ ContextClass ← srcCtx.class^ ] ELSE NIL;
dstCtx.stopMe ← srcCtx.stopMe; -- inheriting REF so Stop signals will propagate
dstCtx.frameNumber ← srcCtx.frameNumber;
dstCtx.shapes ← srcCtx.shapes;
dstCtx.visibleShapes ← srcCtx.visibleShapes;
dstCtx.lightSources ← srcCtx.lightSources;
dstCtx.environment ← srcCtx.environment;
dstCtx.viewInValid ← srcCtx.viewInValid;
dstCtx.eyePoint ← srcCtx.eyePoint;
dstCtx.ptOfInterest ← srcCtx.ptOfInterest;
dstCtx.rollAngle ← srcCtx.rollAngle;
dstCtx.upDirection ← srcCtx.upDirection;
dstCtx.fieldOfView ← srcCtx.fieldOfView;
dstCtx.window ← srcCtx.window;
dstCtx.hitherLimit ← srcCtx.hitherLimit;
dstCtx.yonLimit ← srcCtx.yonLimit;
dstCtx.clippingPlanes ← srcCtx.clippingPlanes;
dstCtx.eyeSpaceXfm ← srcCtx.eyeSpaceXfm;
dstCtx.eyeToNdc ← srcCtx.eyeToNdc;
dstCtx.ndcToPixels ← srcCtx.ndcToPixels;
IF srcCtx.viewer #
NIL
THEN {
dstCtx.viewer ← NEW[ViewerClasses.ViewerRec ← srcCtx.viewer^];
FOR list: Atom.PropList ← srcCtx.viewer.props, list.rest
UNTIL list =
NIL
DO
-- new proplist
element: Atom.DottedPair ← NEW[Atom.DottedPairNode ← list.first^];
dstCtx.viewer.props ← CONS[element, dstCtx.viewer.props];
ENDLOOP;
dstCtx.viewer.props ← PutProp[ dstCtx.viewer.props, $Context3D, dstCtx ];
};
dstCtx.terminal ← srcCtx.terminal;
dstCtx.displayInValid ← srcCtx.displayInValid;
Don't copy pixels, some uses want their own
dstCtx.viewPort ← IF srcCtx.viewPort # NIL THEN NEW[ Imager.Rectangle ← srcCtx.viewPort^]
ELSE NIL;
dstCtx.preferredViewPort ← srcCtx.preferredViewPort;
dstCtx.extentCovered ← srcCtx.extentCovered;
dstCtx.preferredRenderMode ← srcCtx.preferredRenderMode;
dstCtx.displayProps ← NIL;
FOR list: Atom.PropList ← srcCtx.displayProps, list.rest
UNTIL list =
NIL
DO
-- new proplist
element: Atom.DottedPair ← NEW[Atom.DottedPairNode ← list.first^];
dstCtx.displayProps ← CONS[element, dstCtx.displayProps];
ENDLOOP;
dstCtx.autoRedraw ← srcCtx.autoRedraw;
dstCtx.delayClear ← srcCtx.delayClear;
dstCtx.doVisibly ← srcCtx.doVisibly;
dstCtx.antiAliasing ← srcCtx.antiAliasing;
dstCtx.depthBuffering ← srcCtx.depthBuffering;
dstCtx.depthResolution ← srcCtx.depthResolution;
dstCtx.sortSequence ← srcCtx.sortSequence;
dstCtx.props ← NIL;
FOR list: Atom.PropList ← srcCtx.props, list.rest
UNTIL list =
NIL
DO
-- make new proplist
element: Atom.DottedPair ← NEW[Atom.DottedPairNode ← list.first^];
dstCtx.props ← CONS[element, dstCtx.props];
ENDLOOP;
};