How do I draw polygons, like a triangle in dos? Can anyone help?
How do I draw polygons, like a triangle in dos? Can anyone help?
Are you using a library or your own homemade code?
a libary I think, I'm trying to do it in turbo C++ using graphics.h but I cant get it right
Yeah, you're using the BGI graphics library (most likely).
Code:#include <graphics.h> #include <conio.h> int main() { int gdriver = DETECT, gmode; int triangle[8]; // Let's define a triangle with vertices at A(1, 1), B(30, 100), and C(100, 150). triangle[0] = 1; // x of vertex A. triangle[1] = 1; // y of vertex A. triangle[2] = 30; // x of vertex B. triangle[3] = 100; // y of vertex B. triangle[4] = 100; // x of vertex C. triangle[5] = 150; // y of vertex C. triangle[6] = triangle[0]; // Close triangle. triangle[7] = triangle[1]; initgraph(&gdriver, &gmode, ""); // Init the graphics mode. setcolor(15); // Set color to white. drawpoly(4, triangle); // Draw the three sided figure! getch(); closegraph(); // Exit graphics mode. return 0; }
Cool Thanks!
Hmmm. when i compiled that with Borland 3.1 C++ it compiled and linked with out a problem but when i executed it, it said this in the DOS shell "BGI Error: Graphics not initialized (use 'initgraph')", Does anyone have any suggestions why i received that error even thought it linked fine?
U have to use a dos based compiler like Turbo C++ that uses graphics.h which is meant for BGI graphics
>Hmmm. when i compiled that with Borland 3.1 C++ it compiled and linked with out a problem but when i executed it, it said this in the DOS shell "BGI Error: Graphics not initialized (use 'initgraph')", Does anyone have any suggestions why i received that error even thought it linked fine?<
Go to your Borland C++ directory. Look for a subdirectory called BGI. In there, should be a file called egavga.bgi. Copy it to the location of the program. Now try running it.
>U have to use a dos based compiler like Turbo C++ that uses graphics.h which is meant for BGI graphics<
If I'm not mistaken, Borland C++ 3.1 is for DOS.
Hmm.... Actually i do not have that file, could somebody please e-mail that file to [email protected]
Your wish is my command
this code works fine
i tried it with tc++ 2.01
do you think it also works with msvc++ 6 ?
(i can't try it, because i don't have it yet...)
I don't have graphics.h...
can someone please paste the source of it here?