Computer Graphics in C,C++

Wednesday, 6 February 2008

How do you draw a line using Computer graphics?

1. Load graphics Driver using the syntax: int gd,gm; initgraph(&gd,&gm,""); In this initgraph is a function defined in graphics.h header file. In this function gd is for graphics driver and gm is for graphics mode.Third argument is path to your .bgi file. You are preferred to keep your all .bgi and .chr files in bin folder so no need to give path for these things. .BGI files are graphics adapter so for good graphics you should use enhanced adapter you can take more details about these from help of turbo C++ IDE. Well, you can use EGAVGA.bgi.

2.Now You can use any graphics function like line, circle, rectangle etc. For drawing a line you can use following syntax: line(100,100,300,100); These are initial point and final points of a line respectively.

3.Finally you should close the graphics environment by using closegraph(); ,so control will return back to the text mode. It is not mandatory , but it is a good practice.

No comments:

Post a Comment