ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
Revision: 2.5
Committed: Tue Feb 25 02:47:22 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.4: +2 -57 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

# Content
1 /* RCSid $Id$ */
2 /*
3 * driver.h - header file for interactive device drivers.
4 */
5
6 #include "copyright.h"
7
8 struct driver { /* driver functions */
9 void (*close)(); /* close device */
10 void (*clear)(); /* clear device */
11 void (*paintr)(); /* paint rectangle */
12 int (*getcur)(); /* get cursor position */
13 void (*comout)(); /* command line output */
14 void (*comin)(); /* command line input */
15 void (*flush)(); /* flush output */
16 double pixaspect; /* pixel aspect ratio */
17 int xsiz, ysiz; /* device size */
18 int inpready; /* input ready on device */
19 };
20 /* magic numbers for verification */
21 #define COM_SENDM 0x6f37
22 #define COM_RECVM 0x51da
23 /* stream commands */
24 #define COM_CLEAR 0
25 #define COM_PAINTR 1
26 #define COM_GETCUR 2
27 #define COM_COMOUT 3
28 #define COM_COMIN 4
29 #define COM_FLUSH 5
30 #define NREQUESTS 6 /* number of valid requests */
31
32 extern struct device { /* interactive device */
33 char *name; /* device name */
34 char *descrip; /* description */
35 struct driver *(*init)(); /* initialize device */
36 } devtable[]; /* supported devices */
37
38 extern char dev_default[]; /* default device name */
39
40 #define MB1 ('\n') /* mouse button 1 */
41 #define MB2 ('\r') /* mouse button 2 */
42 #define MB3 (' ') /* mouse button 3 */
43 #define ABORT ('C'-'@') /* abort key */
44
45 /*
46 * struct driver *
47 * dname_init(name, id)
48 * char *name, *id;
49 * {
50 * Initialize device and return pointer to driver
51 * functions. Returns NULL if an error occurred.
52 * The name string identifies the driver,
53 * and the id string identifies the client.
54 * A device can be open by at most one client.
55 * Be verbose in error reports; call eputs().
56 * If device has its own error output, set erract.
57 * }
58 * (*dev->close)()
59 * {
60 * Close the device. Reset error vectors.
61 * }
62 * (*dev->clear)(xres, yres)
63 * int xres, yres;
64 * {
65 * Clear the device for xres by yres output. This call will
66 * be made prior to any output.
67 * }
68 * (*dev->paintr)(col, xmin, ymin, xmax, ymax)
69 * COLOR col;
70 * int xmin, ymin, xmax, ymax;
71 * {
72 * Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax)
73 * with the color col.
74 * }
75 * (*dev->getcur)(xp, yp)
76 * int *xp, *yp;
77 * {
78 * Get the cursor position entered by the user via mouse,
79 * joystick, etc. Return the key hit by the user (usually
80 * MB1 or MB2). Return ABORT to cancel.
81 * Can be NULL for devices without this capability.
82 * }
83 * (*dev->comout)(out)
84 * char *out;
85 * {
86 * Print the string out on the device command line. If the
87 * string ends with '\n', the message is considered complete,
88 * and the next call can erase it.
89 * }
90 * (*dev->comin)(in, prompt)
91 * char *in, *prompt;
92 * {
93 * Print a prompt then read an edited input command line
94 * assuming the in buffer is big enough. Unless prompt is NULL,
95 * the driver may substitute its own rview command. This is
96 * the most reliable way to repaint areas of the screen.
97 * If the user enters an unrecognized control character,
98 * terminate input and return the string with only that character.
99 * The input string should not contain a newline. The routines in
100 * editline.c may be useful. Comin must work in consort with comout.
101 * }
102 * (*dev->flush)()
103 * {
104 * Flush output to the display. This is guaranteed to be called
105 * frequently enough to keep the display up to date.
106 * This is an ideal time to check for device input.
107 * This function can be NULL for devices that don't need it.
108 * }
109 * xsiz, ysiz
110 * The maximum allowable x and y dimensions. If any
111 * size is allowable, these should be set to MAXRES.
112 * inpready
113 * This variable should be made positive asynchronously
114 * when characters are ready on the input. (Often easiest
115 * to check for input during calls to paintr.)
116 */
117
118 #ifdef NOPROTO
119
120 extern void editline();
121 extern void tocombuf();
122 extern int fromcombuf();
123 extern struct driver *slave_init();
124 extern struct driver *comm_init();
125 extern int new_ctab();
126 extern int get_pixel();
127 extern void make_gmap();
128 extern void set_cmap();
129 extern void map_color();
130
131 #else
132 /* defined in editline.c */
133 extern void editline(char *buf, int (*c_get)(), void (*s_put)());
134 extern void tocombuf(char *b, struct driver *d);
135 extern int fromcombuf(char *b, struct driver *d);
136 /* defined in devcomm.c */
137 extern struct driver *slave_init(char *dname, char *id);
138 extern struct driver *comm_init(char *dname, char *id);
139 /* defined in colortab.c */
140 extern int new_ctab(int ncolors);
141 extern int get_pixel(COLOR col, void (*set_pixel)());
142 extern void make_gmap(double gam);
143 extern void set_cmap(BYTE *rmap, BYTE *gmap, BYTE *bmap);
144 extern void map_color(BYTE rgb[3], COLOR col);
145
146 #endif