Open In App

Basic Graphic Programming in C++

Introduction
So far we have been using C language for simple console output only.  Most of us are unaware that using C++, low level graphics program can also be made. This means we can incorporate shapes,colors and designer fonts in our program. This article deals with the steps to enable the DevC++ compiler to generate graphics .
Configuring DevC++

Now we are done with configuring of the DevC++ to support graphics programming. We shall write our very first graphics program now.
Running the first graphics program



  1. Open DevC++. Click file ->New ->Project.
  2. Make sure you get the Console Graphics option. However, we are not going to click on it.
  3. Choose Empty Project option and Give a project name and make sure the selected language is C++.
  4. Copy the following code to the editor window.
    #include<graphics.h>
    #include <conio.h>
    int main()
    {
        int gd = DETECT, gm;
        initgraph(&gd,&gm, "C:\\tc\\bgi");
        circle(300,300,50);
        closegraph();
        getch();
    }
    
    
  5. Go to “Project” menu and choose “Project Options” (or just press ALT+P).
  6. Go to the “Parameters” tab In the “Linker” field, enter the following text:
    -lbgi
    -lgdi32
    -lcomdlg32
    -luuid
    -loleaut32
    -lole32
  7. Click OK and Compile and run the project and you’ll get this output:

Program Explanation



Article Tags :