Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. graphics in c++ console program

graphics in c++ console program

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++htmlcomgraphics
4 Posts 4 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sai Yasodharan
    wrote on last edited by
    #1

    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

    B M E 3 Replies Last reply
    0
    • S Sai Yasodharan

      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

      B Offline
      B Offline
      bob16972
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • S Sai Yasodharan

        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

        M Offline
        M Offline
        Matthew Faithfull
        wrote on last edited by
        #3

        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 and graphresult 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.

        1 Reply Last reply
        0
        • S Sai Yasodharan

          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

          E Offline
          E Offline
          El Corazon
          wrote on last edited by
          #4

          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)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups