Graph Unit ßßßßßßßßßßßßßß The Graph unit (GRAPH.TPU) implements a complete library of over 50 graphics routines that range from bit-oriented routines to high-level calls. Go to GRAPH.TPU Functions and Procedures Go to GRAPH.TPU Constants and Types Compiling : To compile a program that uses the Graph unit, you don't need any external files. (Of course, you'll need your program's source code, the compiler, and access to the standard units in TURBO.TPL). Running : To run a program that uses the Graph unit, you'll need one (or more) of the graphics drivers (.BGI files) in addition to your .EXE program. If your program uses any stroked fonts, you'll need one or more font (.CHR) files. GRAPH.TPU Constants and Types ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Constants: Bar3D Constants BitBlt Operators Clipping Constants Color Constants Colors for the 8514 Fill Pattern Constants Graphics Drivers Graphics Modes for Each Driver Justification Constants Line-Style and Width Constants Text-Style Constants Types: ArcCoordsType FillPatternType FillSettingsType Graphics Memory Pointers LineSettingsType PaletteType PointType TextSettingsType ViewPortType GRAPH.TPU Functions and Procedures ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß These are the functions and procedures that make up the Graph unit: Arc Bar Bar3D Circle ClearDevice ClearViewPort CloseGraph DetectGraph Drawpoly Ellipse FillEllipse FillPoly FloodFill GetArcCoords GetAspectRatio GetBkColor GetColor GetDefaultPalette GetDriverName GetFillPattern GetFillSettings GetGraphMode GetImage GetLineSettings GetMaxColor GetMaxMode GetMaxX GetMaxY GetModeName GetModeRange GetPalette GetPaletteSize GetPixel GetTextSettings GetViewSettings GetX GetY GraphDefaults GraphErrorMsg GraphResult ImageSize InitGraph InstallUserDriver InstallUserFont Line LineRel LineTo MoveRel MoveTo OutText OutTextXY PieSlice PutImage PutPixel Rectangle RegisterBGIdriver RegisterBGIfont RestoreCrtMode Sector SetActivePage SetAllPalette SetAspectRatio SetBkColor SetColor SetFillPattern SetFillStyle SetGraphBufSize SetGraphMode SetLineStyle SetPalette SetRGBPalette SetTextJustify SetTextStyle SetUserCharSize SetViewPort SetVisualPage SetWriteMode TextHeight TextWidth GraphDefaults (procedure) (Graph unit) ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Homes the current pointer (CP) and resets the graphics system to specified default values. Declaration: procedure GraphDefaults; Target: Real, Protected Remarks: Homes the current pointer (CP) and resets the graphics system to the default values for viewport palette draw and background colors line style and line pattern fill style, fill color, and fill pattern active font, text style, text justification, and user Char size Restrictions: Must be in graphics mode. Sample Code: GrfDeflt.PAS DetectGraph (procedure) (Graph unit) ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Checks the hardware and determines which graphics driver and mode to use. Declaration: procedure DetectGraph(var GraphDriver, GraphMode: Integer); Target: Real, Protected Remarks: DetectGraph returns the detected driver and mode value that can be passed to InitGraph, which will then load the correct driver. If no graphics hardware was detected, the GraphDriver parameter and GraphResult return a value of grNotDetected. Unless instructed otherwise, InitGraph calls DetectGraph, finds and loads the correct driver, and initializes the graphics system. The only reason to call DetectGraph directly is to override the driver that DetectGraph recommends. When you pass InitGraph a GraphDriver other than Detect, you must also pass a valid GraphMode for the driver requested. See Also: CloseGraph GraphResult InitGraph Sample Code: DetctGrf.PAS InitGraph (procedure) (Graph unit) ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Initializes the graphics system and puts the hardware into graphics mode. Declaration: procedure InitGraph(var GraphDriver:Integer; var GraphMode: Integer; PathToDriver: string); Target: Real, Protected Remarks: If GraphDriver is equal to Detect, a call is made to any user-defined autodetect routines and then DetectGraph. If graphics hardware is detected, the appropriate graphics driver is initialized, and a graphics mode is selected. If GraphDriver is not equal to 0, the value of GraphDriver is assumed to be a driver number. That driver is then selected, and the system is put into the mode specified by GraphMode procedure If you override autodetection in this manner, you must supply a valid GraphMode parameter for the driver requested. PathToDriver specifies the directory path where the graphics drivers can be found. If PathToDriver is null, the driver files must be in the current directory. Normally, InitGraph loads a graphics driver by allocating memory for the driver (through GraphGetMem), then loads the appropriate .BGI file from disk. As an alternative to this dynamic loading scheme, you can link a graphics driver file (or several of them) directly into your executable program file. Do this by first converting the .BGI file to an .OBJ file (using the BINOBJ utility), then place calls to RegisterBGIdriver in your source code (before the call to InitGraph) to register the graphics driver(s). When you build your program, you must link the .OBJ files for the registered drivers. You can also load a BGI driver onto the heap and then register it using RegisterBGIdriver. If memory for the graphics driver is allocated on the heap using GraphGetMem, that memory is released when a call is made to CloseGraph. After calling InitGraph, GraphDriver is set to the current graphics driver, and GraphMode is set to the current graphics mode. If an error occurs, both GraphDriver and GraphResult (a function) return one of the following grXXXX constant values: grNotDetected, grFileNotFound, grInvalidDriver, grNoLoadMem, or grInvalidMode. See Also: CloseGraph DetectGraph GraphResult RestoreCrtMode SetGraphBufSize SetGraphMode Sample Code: InitGrf.PAS GraphResult (function) (Graph unit) ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Returns an error code for the last graphics operation. Declaration: function GraphResult: Integer; Target: Real, Protected Remarks: The following routines set GraphResult: Bar GetGraphMode SetAllPalette Bar3D ImageSize SetFillPattern ClearViewPort InitGraph SetFillStyle CloseGraph InstallUserDriver SetGraphBufSize DetectGraph InstallUserFont SetGraphMode DrawPoly PieSlice SetLineStyle FillPoly RegisterBGIdriver SetPalette FloodFill RegisterBGIfont SetTextJustify SetTextStyle See Also: DetectGraph DrawPoly GraphErrorMsg Sample Code: Grfreslt.PAS CloseGraph (procedure) (Graph unit) ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Shuts down the graphics system. Declaration: procedure CloseGraph; Target: Real, Protected Remarks: CloseGraph restores the original screen mode before graphics was initialized and frees the memory allocated on the heap for the graphics scan buffer. CloseGraph also deallocates driver and font memory buffers if they were allocated by calls to GraphGetMem and GraphFreeMem. Restrictions: Must be in graphics mode. See Also: DetectGraph InitGraph RestoreCrtMode SetGraphMode Sample Code: CloseGrf.PAS