Creating a 2D graphics using DOC is easy if you are using turbo C++. This software for C++ coding have built in libraries of graphics. Many others c++ editors supports graphic.h libraries. But if you are using DEV-C++ then you have to save graphics.h library in dev.cpp folder.
Micheal Main develo
ps the BGI library to use under the MinGW for windows web applications.This BGI library renamed as winBGIm. You can use this library in DEV C++ and do specific tasks of graphics like graphics console applications and others.
INSTALLATION:
To install this library (graphics.h) you must have DEV C++ IDE.
Download DEV C++ from this site DEV C++.setup
After downloading DEV C++ you have to download libraries.
- graphics.h library from this site graphics.h
- libbgi.a file from this site libbgi.a
Place these two files in main folder of libraries
- graphics.h file in C:/program files/dev c++/include
- libbgi.a file in C:/program files/dev c++/lib
CONFIGURATION:
At last step you’ve downloaded & installed the WinBGIm, now you have to configure it to use under Dev-C++. You’ve to set some project options in Dev-C++ in order to run WinBGIm references properly.
Follow the steps below to set proper project options for WinBGIm.
Follow the steps below to set proper project options for WinBGIm.
1. Go to the “File” menu and select “New”, “Project”,Choose “Empty Project” and make sure “C++ project” is selected. Give your project suitable name and click on “Ok”.
OR
1. You can create individual C++” source file” instead of “project”. Go to the “File” menu and select “New Source File” OR Go to the “Project” menu and select “New File”.
2. Go to “Project” menu and choose “Project Options”.
3. Go to the “Parameters” tab.
4. In the “Linker” field, enter the following text:
3. Go to the “Parameters” tab.
4. In the “Linker” field, enter the following text:
- -lbgi
- -lgdi32
- -lcomdlg32
- -luuid
- -loleaut32
- -lole32
5.Click “Ok” to save settings.
Now you’ve done with the configuration for WinBGIm. Please make sure you’ve done this step properly otherwise compiler will flag error.
Now you’ve done with the configuration for WinBGIm. Please make sure you’ve done this step properly otherwise compiler will flag error.
Testing & Debugging
Now let’s write a small program to test how WinBGIm works. Here is the source code for the program. Type it down,save it with .cpp extension and compile and run to see the results.
#include <graphics.h>
#include<iostream>
using namespace std;
int main()
{
initwindow(800,600);
circle(200,300,600);
while(!kbhit());
closegraph();
return 0;
}
This is the program for displaying circle with respective parameters on window of size 800×600.This window will close when you press any key.If you’ve made settings correctly then you can view the graphics,without any problem.
0 comments:
Post a Comment