BGI (Borland Graphics Interface) is ancient as is turbo c++ IDE but nevertheless they are still used in our schools and colleges. Plus they do not work in windows environment (support for native DOS has been completely removed in windows vista/7).If you try to compile the source code with including “graphics.h” in code::blocks IDE then is show error because “graphics.h” only run in turbo.For code::blocks you have to setup winBGIm library.
There are many alternative to winBGIm ,But BGI is good for beginners because you don’t have to worry about whole new fancy functions,classes etc.
WinBGIm is BGI graphics library ported to computer by by Michael Main at the University of Colorado.
Before i start, i must tell you that this guide is written in accordance with code::blocks IDE.
Lets get started:
There are many alternative to winBGIm ,But BGI is good for beginners because you don’t have to worry about whole new fancy functions,classes etc.
WinBGIm is BGI graphics library ported to computer by by Michael Main at the University of Colorado.
Before i start, i must tell you that this guide is written in accordance with code::blocks IDE.
Lets get started:
- First download WinBGIm from http://winbgim.codecutter.org/
- Extract it.
- Copy graphics.h and winbgim.h files in include folder of your compiler directory
- Copy libbgi.a to lib folder of your compiler directory
- In code::blocks open Settings >> Compiler and debugger >>linker settings
- click Add button in link libraries part and browse and select libbgi.a file
- In right part (ie. other linker options) paste commands -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
- click Ok
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| #include <graphics.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <conio.h> #include<math.h> #include<dos.h> #include<string.h> #include<iostream> #include<ctime> //using namespace std; int main( void ) { int gdriver = DETECT, gmode, errorcode; initgraph(&gdriver,&gmode, "d:\\tc\\bgi" ); setfillstyle(SOLID_FILL,GREEN); setcolor(GREEN); rectangle(50,50,50+400,50+300); floodfill(51,51,GREEN); setfillstyle(SOLID_FILL,RED); setcolor(RED); circle(250,200,100); floodfill(250,200,RED); getch(); closegraph(); return 0; } |