Graphics using Dev-C++

It is common practice to use grpahics library which is called graphics.h in Turbo C++ IDE (Integrated Development Editor). While using Dev-C++ IDE we notice/face a problem that we cannot use graphics.h header file. The reason is that by default Dev-C++ resource of header files does not contain this header file. So that we cannot include or use graphic functions in our C/C++ source files.

Graphics.h Header Files in Dev-C++:

graphics.h header file of C/C++ provides multiple built in functions for displaying different type of graphic objects. These object include rectangle, circle, bar, line and all other relevant functions. We can also use this header file while using Dev-C++ IDE.

Use graphics.h in Dev-C++

To use graphic function in C/C++ while using Dev-C++ IDE we have to follow these steps.

  • Download Graphics.h and winbgim header files.
  • Also download libbgi library.
  • Copy header files files in Dev-C++ header files directory.
  • Copy lib file in lib directory.
  • Start Dev-C++ IDE.
  • Press Ctrl + H (Project -> Project Options from menu)
  • Select Parameters Tab.
  • Paste the follwoing instructions in Linker Textarea.

-lbgi
-lgdi32
-lcomdlg32
-luuid
-loleaut32
-lole32

Dev-C++ header files directory:

C:\Program Files (x86)\Dev-Cpp\MinGW64\include

Dev-C++ lib directory:

C:\Program Files (x86)\Dev-Cpp\MinGW64\lib

Download graphics.h for Dev-C++

All required files to use graphics in Dev-C++ can be download using this link.

Simple Graphic Program Using Dev-C++

The first and simple program that only display a galaxy of circles in C/C++ is as below.

#include<graphics.h>

int main( ){
    initwindow( 400 , 400 , "Graphics using Dev-C++");
    setcolor(YELLOW);
    for(int i=5; i<=150; i+=5) {
    circle(200, 200, i);
    }
        
    getch();
    return 0;
}

Output:

graphics programming in C/C++ using Dev-C++ IDE

C++ graphic functions:

Some of the commonly used graphic functions are bar, circle, rectangle, line and arc.

Comments
i have some error target pattern contain no %.stop
~usman
26/Jan/23 11:19 pm
Login to TRACK of Comments.