Borland Graphics Interface


The Borland Graphics Interface, also known as BGI, is a graphics library bundled with several Borland compilers for the DOS operating systems since 1987. BGI was also used to provide graphics for many other Borland products including the Quattro spreadsheet. The library loaded graphic drivers and vector fonts from disk in order to provide device independent graphics support. It was possible for the programmer to embed the graphic driver into the executable file by linking the graphic driver as object code with the aid of a utility provided by the compiler. There were graphic drivers for common graphic adapters and printers of that time, such as CGA, EGA and VGA. There also were BGI drivers for some kinds of plotters.
The last Borland's C++ IDE for DOS is Borland C++ 3.1. The last C++ environment which supports BGI is Borland C++ 5.02, which works under Windows but can compile DOS programs. BGI was accessible in C/C++ with graphics.lib / graphics.h, and in Pascal via the graph unit.
BGI is less powerful than modern graphics libraries such as SDL or OpenGL, since it was designed for presentation graphics instead of event-based 3D applications. However, it has been considered simpler to code.

Third-party BGI drivers

Given the popularity of Borland compilers, a few independent software developers produced BGI drivers for non-standard video modes, advanced video cards, plotters, printers, and graphics file output.
In 1994 Jordan Hargraphix Software released SVGA BGI drivers version 5.5 that are compatible with some SVGA hardware like ATI or Cirrus Logic cards and VESA VBE-compatible cards. Also there are tweaked VGA drivers for non-standard graphic modes supported by VGA by writing directly into its registers, protected mode driver versions for Turbo Pascal 7.0 and mouse driver. These drivers were shareware and buying them let receiving their source code and technical support; now they are no longer supported and come as abandonware. Main bugs are lack of aligning bytes support in VESA true-color modes and video memory bank switching bug in mouse driver.

Example

The following program, written for Borland Turbo C, initialises the graphics and draws 1000 random lines:

  1. include
  2. include
  3. include
  4. define random % )
int main