Does the program compile?
Make sure you have downloaded and installed WinBGIm properly:
http://codecutter.org/tools/winbgim/
BGI Documentation
http://www.cs.colorado.edu/~main/cs1300/doc/bgi/index.html
or
http://www.csie.nuu.edu.tw/~nschou/Teaching/C++/Doc/Quincy/html/programmerHelp/winbgim/bgi/doc/index.html
Installation with Dev-C++:
http://www.onecore.net/dev-c-graphics.htm
http://www.onecore.net/winbgim-graphics.htm
http://apcsteacher.com/reference/cpp/dev_cpp_setup.htm
If you are not using Dev-C++, make sure to install the header files (
conio.h and
winbgim.h) in
C:\MinGW\include\ and the library files (
libconio.a and
libbgi.a) in
C:\MinGW\lib\ . (Personally, I would also make a hardlink to
winbgim.h as
graphics.h .)
Someone's example programs:
http://www.cs.colorado.edu/~karl/1300.fall05/Programs/
If you are compiling with Dev-C++, make sure you also added the link flags as per the instructions above.
If you are just compiling with MinGW at the command-line, you'll need to link with the libraries explicitly. For example, to compile a program ("
myprog.c") that uses the BGI graphics, your compile command may look something like:
D:\prog\foo> gcc myprog.c -lbgi -lgdi32 -luser32
Finally, when using BGI, remember that you first have to
initgraph() before you can use any graphics. The WinBGIm library gives you an alternative in
initwindow(). Here's an example program (untested!):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <winbgim.h>
const char* message = "Press any key...";
int main()
{
int w, h;
initwindow( 400, 300 );
setbkcolor( WHITE );
cleargraph();
setcolor( BLACK );
setfillstyle( SOLID_FILL, BLUE );
setlinestyle( SOLID_LINE, 0, 5 );
rectangle( 20, 20, 80, 80 );
setcolor( LIGHTCYAN );
w = textwidth( message );
h = textheight( message );
outtextxy( 200 - (w / 2), 50 - (h / 2), message );
getch();
closegraph();
return 0;
}
|
Again, don't forget the documentation links above, which are an invaluable reference full of examples.
Hope this helps.