graphics in c++ console program
-
hi, i tried to execute the following program(which was given in turbo c++ documentation) in vc++. but it gives an error, that graphics.h can't be found. so i copied that graphics.h from turbo c to the vc++'s include folder. now it is showing many errors, which i can't resolve(i even don't understand these errors). i am studying c++ in my college. our syllabus include everything from file handling to all oops concepts. but graphics is not covered in out syllabus. so i decided to learn it on my own. but don't know how to start someone help me please the following code works perfectly in turbo c, but not in vc++
#include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy(); /* draw a diagonal line */ line(0, 0, xmax, ymax); /* clean up */ getch(); closegraph(); return 0; }
Known is a Drop, UnKnown is an Ocean More about me at http://in.geocities.com/slagio2002/me.html
-
hi, i tried to execute the following program(which was given in turbo c++ documentation) in vc++. but it gives an error, that graphics.h can't be found. so i copied that graphics.h from turbo c to the vc++'s include folder. now it is showing many errors, which i can't resolve(i even don't understand these errors). i am studying c++ in my college. our syllabus include everything from file handling to all oops concepts. but graphics is not covered in out syllabus. so i decided to learn it on my own. but don't know how to start someone help me please the following code works perfectly in turbo c, but not in vc++
#include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy(); /* draw a diagonal line */ line(0, 0, xmax, ymax); /* clean up */ getch(); closegraph(); return 0; }
Known is a Drop, UnKnown is an Ocean More about me at http://in.geocities.com/slagio2002/me.html
C++ does not have any "native" "Graphics" support. Most graphics libraries are either vendor specific or API's exposed by the OS. The Turbo C++ graphics library will be borland specific. You will need to refer to Borlands documentation on how to use it correctly. A majority of the programmers here probably (just a guess) have more experience and better command of GDI and GDI+ either directly or through avenues such as MFC classes, GDI+ wrapper classes, or .NET.
-
hi, i tried to execute the following program(which was given in turbo c++ documentation) in vc++. but it gives an error, that graphics.h can't be found. so i copied that graphics.h from turbo c to the vc++'s include folder. now it is showing many errors, which i can't resolve(i even don't understand these errors). i am studying c++ in my college. our syllabus include everything from file handling to all oops concepts. but graphics is not covered in out syllabus. so i decided to learn it on my own. but don't know how to start someone help me please the following code works perfectly in turbo c, but not in vc++
#include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy(); /* draw a diagonal line */ line(0, 0, xmax, ymax); /* clean up */ getch(); closegraph(); return 0; }
Known is a Drop, UnKnown is an Ocean More about me at http://in.geocities.com/slagio2002/me.html
Good old Turbo C++ came with its own DOS/Console graphics library. You would need to port/include probably the whole thing for there to be any chance of this working. If all the source was provided, I seem to remember it was, then there's no reason in principle why this wouldn't compile under MSVC. Things have moved on though in the C++ language and you may hit really tricky problems down the line if you persue this. Functions you're calling in the above code like
initgraph
,setcolor
andgraphresult
are from the Borland graphics library. I still have a copy of Turbo C++ on a Win 3.11 virtual PC with many of my old university projects which were developed in Borland Turbo C++ 0.99 and ported to Unix, Solaris and NextStep platforms with no problems although they didn't make use of the graphics library. Enjoy.Nothing is exactly what it seems but everything with seems can be unpicked.
-
hi, i tried to execute the following program(which was given in turbo c++ documentation) in vc++. but it gives an error, that graphics.h can't be found. so i copied that graphics.h from turbo c to the vc++'s include folder. now it is showing many errors, which i can't resolve(i even don't understand these errors). i am studying c++ in my college. our syllabus include everything from file handling to all oops concepts. but graphics is not covered in out syllabus. so i decided to learn it on my own. but don't know how to start someone help me please the following code works perfectly in turbo c, but not in vc++
#include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int xmax, ymax; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); } setcolor(getmaxcolor()); xmax = getmaxx(); ymax = getmaxy(); /* draw a diagonal line */ line(0, 0, xmax, ymax); /* clean up */ getch(); closegraph(); return 0; }
Known is a Drop, UnKnown is an Ocean More about me at http://in.geocities.com/slagio2002/me.html
as mentioned you cannot copy a vendor graphics library for use elsewhere. TurboC's was for itself only. It didn't even work with the borland C compiler after a few versions later. You can use OpenGL, or DirectX, or a variety of other graphics libraries with VC++.
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)