-- File: BitMap3dImpl.mesa
-- Last edited by Bier on December 18, 1982 1:41 am
-- Author: Eric Allan Bier on June 16, 1982 10:33 am
-- Contents: calls to GraphicsExtra.mesa to double buffer graphics

DIRECTORY
 BitMap3d,
 Graphics,
 GraphicsOps,
 ViewerClasses;

BitMap3dImpl: PROGRAM IMPORTS Graphics, GraphicsOps EXPORTS BitMap3d =
BEGIN

BitmapRef: TYPE = REF READONLY BitmapRep;
BitmapRep: TYPE = GraphicsOps.BitmapRep;

Viewer: TYPE = ViewerClasses.Viewer;

AlternateDisplayContext: TYPE = REF AlternateDisplayContextObj;
AlternateDisplayContextObj: TYPE = BitMap3d.AlternateDisplayContextObj;
-- RECORD [
 -- dc: Graphics.Context,
 -- bitMap: BitmapRef];

DrawAltDisplayContext: PUBLIC PROC [dc: Graphics.Context, altDC: AlternateDisplayContext] = {
 Graphics.SetCP[dc,0,0];
 GraphicsOps.DrawBitmap[dc, altDC.bitMap,
         altDC.bitMap.width, altDC.bitMap.height,
         0,0,
         0,altDC.bitMap.height];
 };
         
GetAltDisplayContext: PUBLIC PROC RETURNS [altDC: AlternateDisplayContext] = {
 bitMap: BitmapRef ← GraphicsOps.NewBitmap[10, 10];
 dc: Graphics.Context ← GraphicsOps.NewContextFromBitmap[bitMap];
 altDC ← NEW[AlternateDisplayContextObj ← [
  dc: dc,
  bitMap: bitMap]];
 };

ResizeBitMap: PUBLIC PROC [viewer: Viewer, altDC: AlternateDisplayContext] = {
 newBitMap: BitmapRef ← GraphicsOps.NewBitmap[viewer.cw, viewer.ch];
 GraphicsOps.SetTargetBitmap[altDC.dc, newBitMap];
 altDC.bitMap ← newBitMap;
 };

Erase: PUBLIC PROC [altDC: AlternateDisplayContext] = {
 mark: Graphics.Mark ← Graphics.Save[altDC.dc];
  Graphics.SetColor[altDC.dc, Graphics.white];
  Graphics.DrawBox[altDC.dc,Graphics.GetBounds[altDC.dc]];
  Graphics.SetColor[altDC.dc, Graphics.white];
  Graphics.Restore[altDC.dc,mark];
 }; -- end of Erase

END.