Jump to content

Borland Graphics Interface

From Alfawiki
Borland Graphics Interface (BGI)
Company typeSoftware library
IndustryComputer graphics
Founded1987
FounderBorland International, Inc.
ProductsGraphics library for DOS-based Borland compilers

The Borland Graphics Interface (BGI) was a graphics toolkit bundled with Borland compilers for DOS beginning in 1987. It was also integrated into other Borland applications, such as the Quattro Pro spreadsheet software.

BGI operated by loading graphic drivers (*.BGI) and scalable vector fonts (*.CHR) from storage, enabling device-independent rendering. Developers had the option to embed these drivers directly into their executables by linking them as object files using the compiler tool bgiobj.exe. The library supported a variety of hardware prevalent at the time, including CGA, EGA, VGA, Hercules, AT&T 400, MCGA, and 3270 PC adapters, alongside certain plotter devices.

The last DOS-based Borland C++ IDE to support BGI was version 3.1 released in 1992; however, Borland C++ 5.02 for Windows (1997) maintained the ability to compile DOS programs utilizing BGI. Access to the library was provided through graphics.lib and graphics.h in C/C++, while Pascal developers used the graph unit.

Although BGI lacked the advanced capabilities of contemporary libraries like SDL or OpenGL, it prioritized straightforward 2D graphics rendering over complex event-driven 3D programming, simplifying development efforts.

Third-party BGI drivers

Thanks to the widespread use of Borland compilers, third-party programmers developed additional BGI drivers catering to unconventional video modes, enhanced video cards, plotters, printers, and output to graphic file formats.

In 1994, Jordan Hargraphix Software introduced SVGA BGI drivers version 5.5 compatible with select SVGA hardware including ATI, Cirrus Logic, and VESA VBE-compliant graphics cards. Their product lineup also featured customized VGA drivers enabling non-standard modes through direct hardware register manipulation, protected mode drivers tailored for Turbo Pascal 7.0, and mouse cursor handlers designed for unsupported video modes. These shareware drivers were distributed with source code and offered technical assistance upon purchase; although official support has ceased, the source code was made publicly available under the MIT License on GitHub as of December 2020. Known limitations include missing byte alignment support in VESA true-color modes—restricting compatibility with Nvidia graphics cards—and video memory bank switching errors that impact mouse operation in high-memory configurations.

Legacy

The Free Pascal compiler incorporates a BGI-compatible library called Graph. Additionally, various implementations of BGI exist for modern platforms (refer to External links).

Example

Below is a sample program written in Borland Turbo C that initializes graphics mode and renders 1000 randomly positioned lines:

<syntaxhighlight lang="c">

  1. include <graphics.h>
  2. include <conio.h>
  3. include <stdlib.h>

int main (int argc, char *argv[]) {

 int i, gd = DETECT, gm;
 initgraph(&gd, &gm, "");
 setbkcolor(BLACK);
 cleardevice();
 outtextxy(0, 0, "Drawing 1000 lines...");
 for (i = 0; i < 1000; i++) {
   setcolor(1 + random(15));
   line(random(getmaxx()), random(getmaxy()), 
        random(getmaxx()), random(getmaxy()));
 }
 getch();
 closegraph();
 return 0;

} </syntaxhighlight>

See also

References

External links

  • SDL_bgi – cross-platform adaptation utilizing SDL2 with additional enhancements.
  • Winbgim – Windows-compatible BGI version featuring extra capabilities.
  • GRX graphics library – offers a largely BGI-compatible component.
  • OpenBGI library – an alternative BGI port for Windows systems.
  • libgraph – Linux-based BGI implementation built on SDL1.
  • Fileformat.info – information on decoding Borland CHR font files.
  • sunet.se – FTP mirror providing tools for CHR font manipulation.