Graphics programming in C Language is discussed rarely. Today I will discuss some important functions of graphics.h in C programming Language and in the next coming article I will make a simple program to demonstrate the use of graphics functions. This is the part one of the article which discuses the important graphics function to create and destroy the graphics environment. In part two I will show you different graphics functions to draw shapes. And in last part I will add a sample program to demonstrate the use of graphics.h library. So let's start with the description of important functions and their use.
Below are the important functions and their description mostly used in graphics applications in C Language.
This function is used to load the graphics drivers and initialize the graphics system. For every function, that uses graphics mode, graphics mode must be initialized before using that function.
void far initgraph(int far *driver, int far *mode, char far *path)
Path determines that path to the specified graphics driver.
Detectgraph function determines the graphics hardware in the system, if the function finds a graphics adapter then it returns the highest graphics mode that the adapter supports.
void far detectgraph(int far *driver, int far *mode)
This function clears the graphics screen contents and return the control to the location (0,0).
void far cleardevice(void)
This function shutdown the graphics mode and returns to the position it was before the initgraph function was called. Closegraph function releases all the resources occupied by the graphics system like memry, fonts, drivers etc…
void far closegraph(void)