Skip to content


Dev-C++ & Graphics

Creating 2D graphics programs under DOS is easy if you’re using [turbo c].There is library file called graphics.h that does the tiresome work for you.But unfortunately this library is borland specific you can’t use it on other compilers.Even though some peoples somehow managed to port it outside the turbo.Some people hacked their own version of graphics.h.One such person is Micheal main,he ported some of borland graphics functions and library.

Micheal main modified BGI library for windows application to be used under MinGW.This BGI library is renamed as WinBGIm.Now you can use all the borland specific functions under Dev-C++.You can access this library from [Here].

If you want, you can Download the WinBGIM Devpack from this link[here] and start coding instead of using method below.

Installation
In order to run graphics programs under Dev-C++ you have to download WinBGIm files.Download the files listed below.

Graphics.h (download to C:\Dev-Cpp\include)

libbgi.a(download to C:\Dev-Cpp\lib)

Once you download the files.Now you have to place into the correct location in Dev-C++ installation folder.Try to locate include and lib folder under your dev-cpp installation.Move these files under the respective folder of include and lib. like e.g. D:\Dev-cpp\ include & D:\Dev-cpp\lib .

Configuration
At last you’ve downloaded & installed the WinBGIm,now you have to configure it to use under Dev-C++.You’ve to set some project options in Dev-C++ in order to run WinBGIm references properly.
Follow the steps below to set proper project options for WinBGIm.

1. Go to the “File” menu and select “New”, “Project”,Choose “Empty Project” and make sure “C++ project” is selected.Give your project suitable name and click on “Ok”.

OR

1. You can create individual C++” source file” instead of “project”.Go to the “File” menu and select “New Source File” OR Go to the “Project” menu and select “New File”.

2. Go to “Project” menu and choose “Project Options”.
3. Go to the “Parameters” tab.
4. In the “Linker” field, enter the following text:

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

5.Click “Ok” to save settings.
Now you’ve done with the configuration for WinBGIm.Please make sure you’ve donw this step properly otherwise compiler will flag error.

Testing & Debugging

Now let’s write a small program to test how WinBGIm works.Here is the source code for the program.Type it down,save it with .cpp extension and compile and run to see the results.

#include <graphics.h>

#include <iostream>

using namespace std;

int main()
{
initwindow(800,600);
circle(200,300,600);
while(!kbhit());
closegraph();
return 0;
}

This is the program for displaying circle with respective parameters on window of size 800×600.This window will close when you press any key.If you’ve made settings correctly then you can view the graphics,without any problem.

What’s included ?
All the borland graphics batteries included,plus some additional written by other contributors of WinBGIm. With WinBGIm you can use most of the borlands graphics function & RGB colors.You can also use detectgraph() and initgraph() or you can use new function called initwindow().You can even use some of the old mouse function such as int mousex() & int mousey() along with getmouseclick() & clearmouseclick().For keyboard functions,you don’t have to include conio.h some of the functions are supported without it like void delay(int millisec),int getch( ),int kbhit( ).

If you want to capture the screen where you’ve created your graphics.You can do it with help of these functions getimage(),imagesize(), printimage(), putimage(), readimagefile() ,writeimagefile().

Help & Support
If you’re into some trouble with installation & configuration,then please post your questions here.But please don’t post homework problems or your custom projects.Google groups is the right place to get answers in such cases.You can even get lot of support with WinBGIm and Dev-C++ at Google groups.If you want to read about the WinBGIm documentation & FAQ then please point yourself [ Here ].

If you’ve any question or suggestion then don’t hesitate to post it here.If you know any alternative than WinBGIm,please post about it here.


13 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Pranav says

    Thanks a lot for this. I used to use Turbo C++ for graphics. But now, the software is outdated and everyone uses Dev C++. I was looking a graphics solution when I encountered this article. Helped a lot. Thanks!

  2. sindhu says

    thanks a lot for the tutorial :) that was very informative, been looking for this.

  3. Eltanin says

    Thank you mahesh, I’ve been looking for such lib for days ;)

  4. Guy Incognito says

    Life saver! Thanks!

  5. Max says

    Muchas gracias!!!! me ayudaste mucho con un trabajo importante que tenĂ­a en la escuela — Thank you very much!!! You helped me to do an important homework.

  6. joisanb says

    Thanks mahesh! Your tips were very useful!

  7. wasif says

    yahoooooooooo!!!!!!!
    i don it thanks 4 this lib i have fun with it….

  8. MathPlayer says

    I have problems in understanding the mouse handler functions. Can anyone help me?

  9. lynchkurvachev says

    Hi, everyone, maybe if you interested with graphical programming using dev c++, you can use allegro library. This library can handle keyboard, mouse, and sound. I have ever try this library, and working great. For the tutorial you can access at http://www.alegro.cc.

  10. Alex says

    #include
    void main()
    {
    cout << "Thanks a ton";
    }

  11. Harsh Gupta says

    hi i want to print a digit in colorfull way just like a in turbo c++ textcolor function use.so ples alternative function for this

  12. Arjav says

    i am getting this error
    E:\devcpp\Dev-Cpp\Makefile.win [Build Error] [main.o] Error 1

Continuing the Discussion

  1. WINBGIm Graphics linked to this post on August 12, 2008

    [...] I’ve discussed installation & configuration of Winbgim with Dev-C++ here. As devpaks for Winbgim are released, things are now much better than before. This article is [...]



Some HTML is OK

or, reply to this post via trackback.