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 (*.BGI
) and vector fonts (*.CHR
) 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 (bgiobj.exe
). 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.
BGIdemoCollage | |
Written in | C++ |
---|---|
Platform | DOS |
Type | library or framework |
The last Borland's C++ IDE for DOS is Borland C++ 3.1 (1992). The last C++ environment which supports BGI is Borland C++ 5.02 (1997), 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.[1]
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.[2]
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 (actually cursor handler for unsupported video modes by standard mouse drivers). These drivers were shareware and buying them let receiving their source code and technical support; now they are no longer supported, but on 19 December 2020 Jordan Hargrave kindly released source code under the MIT License on GitHub.[3] Main bugs are lack of aligning bytes support in VESA true-color modes (so the true-color driver is not suitable for Nvidia graphic cards) and video memory bank switching bug in mouse driver (since real mode addressing space is 1 megabyte, but some video modes require up to 4 megabytes of memory, it is split into 64 kilobyte banks).
Example
The following program, written for Borland Turbo C, initialises the graphics and draws 1000 random lines:
#include <stdio.h>
#include<graphics.h>
#include<conio.h>
void draw (int x, int y, int x1, int y1);
{
putpixel(x+x1 ,y+y1 ,11);
putpixel(x-x1 ,y+y1 ,11);
putpixel(x+x1 ,y-y1 ,11);
putpixel(x-x1 ,y-y1 ,11);
putpixel(x+x1 ,y+y1 ,5);
putpixel(x-x1 ,y+y1 ,5);
putpixel(x+x1 ,y-y1 ,5);
putpixel(x-x1 ,y-y1 ,5);
}
void Brescircle (int x, int y, int r);
{
int x1=0, y1=r;
int d=3-2*r;
draw(x, y, x1, y1);
while (y>=x)
{
x++;
if(d>0)
{
y--;
d=d+4*(x1-y1)+10;
}
else
d=d+4*x1+6;
draw (x, y, x1, y1);
delay(500);
}
}
int main()
{
int x, y,r;
int gd=DETECT, gm;
intigraph(&gd, &gm,"");
printf("ENTER THE VALUE OF X CO-ORDINATE: ");
scanf("%d", &x);
printf("ENTER THE VALUE OF y CO-ORDINATE: ");
scanf("%d", &y);
printf("ENTER THE VALUE OF RADIUS: ");
scanf("%d", &r);
Brescircle(x, y, r);
getch();
return 0;
}
See also
References
- "Computer Graphics", ISRD Group, 2006. ISBN 0070593760
- Freeware BGI drivers, Jordan Hargraphix BGI drivers, Knight Software BGI256
- SuperVGA BGI Drivers for Turbo C/Turbo Pascal/Borland C++
- Turbo C++ 3.0 User's Guide. Borland International, Inc. 1992.
- Borland C++ Library Reference. Borland International, Inc. 1992.
- Borland Graphics Interface (BGI) Documentation
External links
- SDL_bgi is a multiplatform port written in SDL2; it provides several extensions.
- The GRX graphics library contains a BGI subsystem, mostly compatible with the original BGI.
- OpenBGI library is another port for Microsoft Windows.
- libgraph is a BGI implementation for GNU/Linux written in SDL1.
- Fileformat.info page about chr contains some information on how to decode Borland CHR font.
- sunet.se ftp mirror with some CHR font tools.
- Winbgim is a port of BGI for Microsoft Windows; it provides several extensions.