WIN-TC Graphics Library Programming

Source: Internet
Author: User

This article address: http://www.cnblogs.com/archimedes/p/win-tc-graphics-use.html, reprint please indicate source address.

Due to a recent emergency task, a program is required to display some of the graphs in the fractal geometry, for example: Koch curve

Feel the Java Swing interface is too cumbersome, OK, I am not familiar. So intend to use C language to achieve, but do not want too much trouble, so think of WIN-TC (or in the virtual machine directly installed an XP system, online various Win7 64-bit version of the final proof are not reliable), download WIN-TC 2.0 after the direct operation, WIN-TC comes with a lot of templates that can be easily used, such as:

Directly select "BGI Graphics Programming Template", automatically populate the code framework, such as:

The code is as follows:

/*WIN-TC BGI graphic Programming template*/#include"Conio.h"#include"Graphics.h"#defineClosegr ClosegraphvoidINITGR (void)/*BGI Initialization*/{  intGD = DETECT, GM =0;/*and GD = VGA,GM = Vgahi is the same effect*/Registerbgidriver (egavga_driver);/*you may not need the. bgi file support to run after you register BGI driver*/Initgraph (&GD, &GM,"");}intMainvoid) {initgr ();/*BGI Initialization*/  /** * * * This section adds your own code, such as line (25, 25, 220, 220);  Circle (100, 100, 50); Wait, * * **/getch ();/*pause for a moment to see the results of the previous drawing code*/Closegr ();/*Restore text screen mode*/  return 0;}

But running directly will prompt the error: " undefined symbol ' _egavga_driver ' in module test2.c"

If the code of this line is commented out, compiled through, run the console a flash, after the code to add a variety of "getch ()" ... Such methods are not used, in fact, the problem is in front, because there is no graphics drive, the program exits directly, Getch is not executed at all.

On the internet for a long time, either the answer is not correct, or too cumbersome, tossing a will find a solution.

Locate the directory "C:\Win-TC\BGI" of the Egavga.bgi file, and place the Initgraph (&GD, &GM, "") in the above code; To add a path:

" C:\\WIN-TC\\BGI ");

The complete code is as follows:

/*WIN-TC BGI graphic Programming template*/#include"Conio.h"#include"Graphics.h"#defineClosegr ClosegraphvoidINITGR (void)/*BGI Initialization*/{  intGD = DETECT, GM =0;/*and GD = VGA,GM = Vgahi is the same effect*/Registerbgidriver (egavga_driver);/*you may not need the. bgi file support to run after you register BGI driver*/Initgraph (&GD, &GM,"C:\\WIN-TC\\BGI");}intMainvoid) {initgr ();/*BGI Initialization*/  /** * * This section adds your own code, such as*/Line ( -, -, -, -); Circle ( -, -, -); /*Wait, * * **/getch ();/*pause for a moment to see the results of the previous drawing code*/Closegr ();/*Restore text screen mode*/  return 0;}

The first run requires the BGI driver to be registered, and the "Registerbgidriver (egavga_driver)" is not required for later operation; this line of code

After configuring the programming environment, the following work is a programming implementation! O (∩_∩) o haha ~

WIN-TC Graphics Library Programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.