|
The article explains the mode of distribute graphics applications in C++ without include the file EGAVGA.BGI and files of text's sources (.CHR) with the application. Will, now you will see that is very easy.
First is necessary convert the file: "EGAVGA.BGI" in a object file (.OBJ). We going to convert with the utility BGIOBJ.EXE, that is localized in the directory: C:\TC\BGI, you can write in the path:
C:\TC\BGI>BGIOBJ EGAVGA
If the file is done correctly, it should indicate the public name of Driver: AVGA_driver.
You imagine that the application will use the TRIPLEX source, then we going to convert so:
C:\TC\BGI>BGIOBJ TRIP
The public name of the source is: triplex_font.
Now we can to go at the directory in which is localized the program. Open The Turbo C/C++ and create a new project with the option: "Project\Open project....". We should indicate the name for the project. You remember that the name of FILE.EXE has that be similar at the project name.
Well, after then you should add the files that we need it. The mode is with the option: "Project\Add item...." You add the source of the application and the files: EGAVGA.OBJ and TRIP.OBJ.
Edit the code for initiate the mode graphic and add the next lines:
registerbgidriver(EGAVGA_driver);
registerbgifont(triplex_font);
The code should to be similar at example:
#include "conio.h"
#include "graphics.h"
void main(void) {
int tarjeta, modo, error;
registerbgidriver(EGAVGA_driver);
registerbgifont(triplex_font);
detectgraph(&tarjeta, &modo);
initgraph(&tarjeta, &modo, "");
error = graphresult();
if (error) {
printf("%s", grapherrormsg(error));
exit(1);
}
// Draw a circle
fillellipse(200,200,20,20);
while (!kbhit());
}
Coment: Now, only play CTRL + F9 and compile the project. Note that you can distribute the application without include the aditional files ;-)
|