
Unfortunately, graphics.h is a Borland specific library and cannot be used with Dev-C++. Many games and application have been developed using it and there are many resources available on the web.How do I use Borland Graphics Interface (graphics.h)?įor those of you migrating from Borland, you may be wondering where graphics.h is. For more advanced applications you can use OpenGL which offers API for 2D and 3D graphics.

These codes show how to use functions of graphics library and simple applications to learn programming. After you have understood initgraph function then you can use functions to draw shapes such as circle, line, rectangle, etc., then you can learn how to change colors and fonts using suitable functions, then you can go for functions such as getimage, putimage, etc., for doing animation. Initgraph function automatically decides an appropriate graphics driver and mode such that maximum screen resolution is set, getch helps us to wait until a key is pressed, closegraph function closes the graphics mode, and finally return statement returns a value 0 to main indicating successful execution of the program. DETECT is a macro defined in "graphics.h" header file, then we have passed three arguments to initgraph function first is the address of gd, second is the address of gm and third is the path where your BGI files are present (you have to adjust this accordingly where you Turbo C compiler is installed). To begin with we have declared two variables of int type gd and gm for graphics driver and graphics mode respectively, you can choose any other variable name as well.

Let me tell you what the output of this program is, this program initializes graphics mode and then closes it after a key is pressed. Initgraph ( &gd, &gm, "C: \\TC \\BGI" )
