How to write Computer graphics Programming in C language?
While writing computer graphics program in C-Language we have to do few changes in program as follows:
⦁ Add header file for graphics functions as
# include <graphics.h>
⦁ Declare two variables gd, gm( Variable name can be any ) and call initgraph function
int gd=DETECT,gm;
initgraph(&gd,&gm, “full path of BGI file”);
even after placing full path of BGI directory in initgraph function if graphics unable to initialize then do following ulternate procedure by keeping initgraph function .
a. go to file-> DOS Shell and click
b. here you will be in BIN directory. come out of BIN using cd.. command.
c. then type cd BGI and press ENTER.you will enter into BGI Directory.
d. type exit command so that you will reach to program window.
e. after doing above process compile and run your program.
⦁ use putpixel function for plotting pixel on computer screen.
putpixel(x,y,color)
where x and y are coordinates of pixel to be plotted and color means color for pixel. in C language there is color range from 0 to 15. you can choose any color from available.