ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
Revision: 1.2
Committed: Wed Apr 19 22:01:38 1989 UTC (35 years ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.1: +8 -6 lines
Log Message:
changed comments section

File Contents

# Content
1 /* Copyright (c) 1987 Regents of the University of California */
2
3 /* SCCSid "$SunId$ LBL" */
4
5 /*
6 * driver.h - header file for interactive device drivers.
7 *
8 * 2/2/87
9 */
10
11 struct driver { /* driver functions */
12 int (*close)(); /* close device */
13 int (*clear)(); /* clear device */
14 int (*paintr)(); /* paint rectangle */
15 int (*getcur)(); /* get cursor position */
16 int (*comout)(); /* command line output */
17 int (*comin)(); /* command line input */
18 int xsiz, ysiz; /* device size */
19 int inpready; /* input ready on device */
20 };
21
22 extern int stderr_v(); /* error vectors */
23 extern int (*wrnvec)(), (*errvec)(), (*cmdvec)();
24
25 extern struct driver *comm_init(); /* stream interface */
26 /* stream commands */
27 #define COM_CLEAR 0
28 #define COM_PAINTR 1
29 #define COM_GETCUR 2
30 #define COM_COMOUT 3
31 #define COM_COMIN 4
32 #define NREQUESTS 5 /* number of valid requests */
33
34 struct device { /* interactive device */
35 char *name; /* device name */
36 char *descrip; /* description */
37 struct driver *(*init)(); /* initialize device */
38 };
39
40 extern struct device devtable[]; /* supported devices */
41
42 #define MB1 ('\n') /* mouse button 1 */
43 #define MB2 ('\r') /* mouse button 2 */
44 #define MB3 (' ') /* mouse button 3 */
45 #define ABORT ('C'-'@') /* abort key */
46
47 #define MAXRES 4000 /* preposterous display resolution */
48
49 /*
50 * struct driver *
51 * dname_init(name)
52 * char *name;
53 * {
54 * Initialize device and return pointer to driver
55 * functions. Returns NULL if an error occurred.
56 * The name string is used to identify the client.
57 * A device can be open by at most one client.
58 * Be verbose in error reports; call stderr_v().
59 * If device has its own error output, set errvec,
60 * cmdvec and wrnvec.
61 * }
62 * (*dev->close)()
63 * {
64 * Close the device. Reset error vectors.
65 * }
66 * (*dev->clear)(xres, yres)
67 * int xres, yres;
68 * {
69 * Clear the device for xres by yres output. This call will
70 * be made prior to any output.
71 * }
72 * (*dev->paintr)(col, xmin, ymin, xmax, ymax)
73 * COLOR col;
74 * int xmin, ymin, xmax, ymax;
75 * {
76 * Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax)
77 * with the color col. Can call repaint() if necessary.
78 * }
79 * (*dev->getcur)(xp, yp)
80 * int *xp, *yp;
81 * {
82 * Get the cursor position entered by the user via mouse,
83 * joystick, etc. Return the key hit by the user (usually
84 * MB1 or MB2). Return ABORT to cancel.
85 * Can be NULL for devices without this capability.
86 * }
87 * (*dev->comout)(out)
88 * char *out;
89 * {
90 * Print the string out on the device command line. If the
91 * string ends with '\n', the message is considered complete,
92 * and the next call can erase it.
93 * }
94 * (*dev->comin)(in)
95 * char *in;
96 * {
97 * Read an edited input string from the command line. If
98 * an unrecognized control character is entered, terminate
99 * input and return the string with only that character.
100 * The input string should not contain a newline.
101 * Must work in consort with comout.
102 * }
103 * xsiz, ysiz
104 * The maximum allowable x and y dimensions. If any
105 * size is allowable, these should be set to MAXRES.
106 * inpready
107 * This variable should be made positive asynchronously
108 * when characters are ready on the input. (Often easiest
109 * to check for input during calls to paintr.)
110 */