Bgi
Bgi
Graphics Programming can be classified into: 1. Graphics with BGI 2. Mode 13h Programming 3. VESA Programming
28
BGI stands for Borland Graphics Interface. Working with BGI refers to working with driver files (with BGI extension). So we are in need of BGI files that are to be initialized with initgraph( ) function. Programming with BGI is considered to be quite old. In my experience, BGI is used only by Indian Programmers! Other International Programmers use mode 13h. Even though BGI is slow, we can do lots of graphics with it. It will be highly beneficial for the beginners.
One of the common mistakes very often committed by Indian Programmers is to use DETECT macro with initgraph( ) as shown above. First of all we must know what DETECT will do in a program: it automatically detects the systems graphics adapter and chooses the mode that provides the highest resolution for that adapter. So we must understand that DETECT may detect a mode, which we might not expect! And it will be a very serious problem! If you write a program for 640x480 resolution, and if DETECT detects a mode that has only 320x200 resolution, you cannot see a part of the image. It is a costly mistake! So the right declaration for a bug free program is:
int gdriver = VGA, gmode = VGAHI; initgraph( &gdriver, &gmode, "c:\\tc\\bgi");
Another problem with DETECT is that even if you have SVGA it will detect VGA.
142 A to Z of C
packages to support SVGA. Jordan Hargraphix Softwares SuperVGA/Tweak BGI drivers are the widely used drivers.
A to Z of C 143
SuperVGA 65536-color 0) 320x200x65536 1) 640x350x65536 2) 640x400x65536 3) 640x480x65536 4) 800x600x65536 5) 1024x768x65536 6) 1280x1024x65536 SuperVGA 24-bit color 0) 320x200x24-bit 1) 640x350x24-bit 2) 640x400x24-bit 3) 640x480x24-bit 4) 800x600x24-bit 5) 1024x768x24-bit 6) 1280x1024x24-bit Tweaked 16-color 0) 704x528x16 1) 720x540x16 2) 736x552x16 3) 752x564x16 4) 768x576x16 5) 784x588x16 6) 800x600x16 Tweaked 256-color 0) 320x400x256 1) 320x480x256 2) 360x480x256 3) 376x564x256 4) 400x564x256 5) 400x600x256 6) 320x240x256 7) 360x350x256
144 A to Z of C
S3 Accelerator 16/256/32768-color 0) 640x480x256 1) 800x600x256 2) 1024x768x256 3) 800x600x16 4) 1024x768x16 5) 1280x960x16 6) 1280x1024x16 7) 640x480x32768 Turbo C++3.0s setcolor( ) function was not written with upward compatibility. setcolor( ) function receives integer value as color value. So setcolor( ) function cannot work if we provide a long value (a value above 32767, say 50000). Inorder to make the setcolor( ) function to work, Jordan Hargraphix Softwares graphics functions use certain ! rules. More details and documentation are found on CD