home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Education Master 1994 (4th Edition)
/
EDUCATIONS_MASTER_4TH_EDITION.bin
/
files
/
progmisc
/
bgidraw
/
bgidraw.exe
/
lha
/
HOWTO.DOC
< prev
next >
Wrap
Text File
|
1993-05-03
|
9KB
|
205 lines
How To Use BGI-Draw
Start BGI-Draw like any DOS-based program by typing BD at
the DOS prompt, or from within a batch file. You can
optionally follow BD with a space and a filename to
immediately start editing or creating a file.
C/C++ or Pascal
If the file is a new one, BD will try to guess what
language you are using by the extension of the filename. If
your file ends in .CPP, or .C, it will create C source code.
If .PAS, then a pascal source file will be created. If you
use any other extension, then you will be asked to pick your
language.
NOTE: PASCAL PROGRAMMERS, if the first letter of your file
extension is C, then BD will think you want a C source code
file.
Video Modes
A menu will appear listing the video modes supported by
your computer. (If you have Hercules, no menu appears, since
your computer supports only one graphics mode.) Pick the same
mode as your finished program will be using. If you are
developing a program for EGA, then you don't want to draw
your picture in VGA graphics.
The Main Menu
Then the main menu appears. It consists of 30 colorful
icons, which can be pointed to with the mouse or arrow keys.
To Use The Keyboard
If you don't have a mouse, or if you want to control the
program from the keyboard, you'll notice that the arrow and
other movable objects in BGI-Draw can be moved with the
arrow keys. You can also use [Home], [Pg Up], [Pg Down] or
[End] to move diagonally. When the [Num Lock] key is on, the
number keys move the arrow in large jumps, for fast access to
any area of the screen.
Conventions
There are several occasions in which the program will ask
for a yes or no answer. To answer yes, you can press [y],
[Enter] or the left mouse button. To answer no, press [n],
[Esc] or the right mouse button.
When asked to type a number or string, the mouse has no
effect in some dialogs, so you must use [Enter] or [Esc].
[Enter] generally indicates you want the program to accept
what you have typed, and [Esc] means you want to abandon the
current operation.
Saving Files
BGI-Draw updates the source code file on the fly, meaning
that as soon as you perform an operation, the source code
file is updated. "Saving" the file is not required and no
specific save function is provided.
Using The Files In Your Own Programs
We assume you have done enough graphics programming to
realize the importance of BGI-Draw. If so, you'll also know
how to initialize a graphics mode within your program and
create/use integer variables. The source code created by
BGI-Draw is purely on-screen graphics, without the necessary
start-up code, optional TPU or OBJ headers, etc. You simply
cut and paste it into your program source code with your
favorite programming environment or text editor. Briefly:
C/C++
You'll need GRAPHICS.LIB, GRAPHICS.H, and possibly some
.BGI and .CHR files available where your compiler can find
them. The *.BGI files are the drivers for various graphics
modes, and the *.CHR files are fonts. Default Font, (font
#0) is built-in. These can also be incorporated into your
.EXE files by creating .OBJ files from them. See your
Borland manuals, or purchase C-Magic from Another Company if
you want stand-alone .EXE files.
Create a project file including your main source code
file and GRAPHICS.LIB. At the top of your main file add the
line:
#include "graphics.h"
create variables graphdetect, and graphmode as integers.
Assign values to graphdetect and graphmode to start the
proper video mode. See the chart below.
Use initgraph as in the following example:
#include "graphics.h"
int graphdetect, graphmode;
int vx, vy;
void main(){
graphdetect = 6;
graphmode = 2;
initgraph(&graphdetect, &graphmode,"");
vx = 0;
vy = 0;
/* put your picture source code here */
/* see Movable Pictures below */
}
Pascal
You'll need GRAPH.TPU, (or GRAPH.TPP), and possibly some
.BGI and .CHR files available where your compiler can find
them. The *.BGI files are the drivers for various graphics
modes, and the *.CHR files are fonts. Default Font, (font
#0) is built-in. These can also be incorporated into your
.EXE files by creating .OBJ files from them. See your
Borland manuals, or purchase Pascal Magic from Another
Company if you want stand-alone .EXE files.
Create a main source code file with GRAPH in the USES line.
create variables graphmode, and graphdetect as integers.
Assign values to graphmode and graphdetect to start the
proper video mode. See the chart below.
Use initgraph as in the following example:
program blahblah;
uses graph;
var
graphdetect, graphmode : integer;
vx, vy : integer;
begin
graphdetect := 1;
graphmode := 0;
initgraph(graphdetect,graphmode,'');
vx := 0;
vy := 0;
(* put your picture source code here *)
end;
Movable Pictures
You'll notice integer variables vx and vy in the above
examples. Because you may want to make movable pictures for
your program, all horizontal locations are prefaced with "vx
+" and all vertical locations are prefaced with "vy +".
Normally, you'd make sure vx and vy are both 0, so that the
picture shows on the screen exactly like you have made it in
BGI-Draw. But for animations, split screens, or pop-up
icons, etc, you'll want to control vx and vy to move your
pictures around.
Graphdetect and Graphmode for Various Video Modes
BGI-Draw Mode Name Size Colors Graphdetect Graphmode
1 CGA 640 x 200 2 1 4
2 CGA 320 x 200 4 1 0
3 EGA 640 x 200 16 4 0
4 EGA 640 x 350 16 3 1
5 Herc 720 x 348 2 7 0
6 VGA 640 x 480 16 6/9 2
7 VGA 320 x 200 256 16* 0
8 SVGA 640 x 480 256 16* *
* Borland does not supply drivers for 256-color modes, but
many third party drivers are available. Most use 16 for a
graphdetect number. In the case of SVGA modes, the Graphmode
number will vary with the manufacturer of the driver.
Summary
Simply start BD, answer the questions, and start drawing.
Most of the drawing tools work just like the tools in any
drawing or paint program, except there are also some tools
you've probably never seen before. (Relax, you don't have to
learn to work all the tools to use this program!) When done,
simply quit the program, and you'll have a source code file
which you can incorporate into your program.
Space and Strip
Included in your BGI-Draw package are two small programs
called SPACE.EXE and STRIP.EXE which can be used to change
the indentation of lines in a source code file. When you cut
and paste bits of source code together from different files,
it is nice to be able to achieve the same indentation without
adding or removing spaces line by line. To use these
programs simply call them by name at the DOS prompt and
follow the on-screen directions.
See the next chapter to find out about all the features
available within BGI-Draw, and how to use them.
_____________________________________________________________
End of file.