2. SIMPLE COMPLETE FORTRAN PROGRAM USING FOG
2.1 Simple Example
This example is the simplest possible FOG program that can draw a line
on the screen and maintain it. The line is drawn from the top left hand
corner to the bottom right hand corner of the major image area.
The annotation numbers refer to the notes below the example.
C 1
INTEGER D(8)
C 2
D(1) = 0
CALL DCHOOS (D, 1)
C 3
CALL DINIT (D,1)
C 4
CALL SETPT (0,1023,0)
C 5
CALL LINE (1023,-1023,1)
C 6
PAUSE
STOP
END
Notes
- The programmer must provide an integer array (or arrays) where the display
file is (or display files are) to be generated.
The size of the array to be provided depends on:
- the number of display files that are to occupy the
array (1 in this example);
- the number of calls to routines which generate display
orders (in this example one of SETPT and one of LINE);
- the number of display orders generated by each routine (the
programmer can find out the number of display orders generated
by each routine by reference to Appendix D).
In this example 8 locations are required, made up of 4 (minimum size)
+ 2 (for SETPT) + 2 (for LINE). (On the ACL PDP15 with arbitrary vector
hardware, SETPT and LINE never generate more than 2 display orders.)
- The program must specify, using DCHOOS, in which locations
subsequent FOG routines are to generate a display file.
In this example, the display file will start at the array element D(1).
If D(1)=0 on entry to DCHOOS as in this example, then DCHOOS ensures that on
exit there is a minimum executable file for the VT processor to obey.
A fuller definition of DCHOOS is contained in Section 3.1.
- The program calls DINIT to command the VT15 processor to execute the specified
file; in this example the display file starts at the array. element D(1).
On exit from DINIT, the VT15 is executing a display file which is
valid (because DCHOOS has been called) but which contains no
display orders that can generate a visible image. Therefore, the screen
is blanked if it is not already blank.
- The effect of the SETPT call is to create display orders which set the
plotting position at the point (0,1023) with respect to an origin (0,0) at the
bottom left-hand corner of the screen. The screen remains blank (because of the
third argument being 0). Orders are being added to the display file while
the VT15 processor is executing it. FOG ensures that this will not cause
problems.
- The effect of the LINE call is to create display orders which draw a
visible vector with, in this example, an X-increment of 1023 and a Y-increment
of -1023 (from point (0,1023) to (1023,0)).
The line appears at this time (on the first VT15 cycle after LINE is called).
- The PAUSE is necessary in this example otherwise the program will exit and
the image will disappear as soon as control is returned to the disc operating
system (DOS). In PDP15 FORTRAN, the PAUSE statement waits for the user to type
ctrl P on the system teletype. In a typical interactive graphics
program a steady image is maintained when the program is waiting for the next
user-input so a PAUSE would not be necessary.
Variations
- Although DCHOOS must be called before any of the other FOG routines
in this example, DINIT need not be called before the image-generating
routines. If DINIT is called after all the image-generating routines,
the picture will not appear on the screen until the complete display file
is present, instead of individual lines appearing as they are called.
With a complex picture, this would make a noticeable difference.
- If the SETPT call is omitted, LINE would start from a new plotting
position (the endpoint of the previous LINE) on each VT15 cycle.