ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
Revision: 2.9
Committed: Tue Mar 30 16:13:01 2004 UTC (20 years ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9
Changes since 2.8: +124 -32 lines
Log Message:
Continued ANSIfication. There are only bits and pieces left now.

File Contents

# Content
1 /* RCSid $Id: driver.h,v 2.8 2003/08/20 10:00:09 schorsch Exp $ */
2 /*
3 * driver.h - header file for interactive device drivers.
4 */
5 #ifndef _RAD_DRIVER_H_
6 #define _RAD_DRIVER_H_
7
8 #include "color.h"
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 typedef struct driver *dr_initf_t(char *dname, char *id);
15 typedef int dr_getchf_t(void);
16 typedef void dr_newcolrf_t(int ndx, int r, int g, int b);
17
18 typedef void dr_closef_t(void);
19 typedef void dr_clearf_t(int, int);
20 typedef void dr_paintrf_t(COLOR col, int xmin, int ymin, int xmax, int ymax);
21 typedef int dr_getcurf_t(int*,int*);
22 typedef void dr_comoutf_t(char*);
23 typedef void dr_cominf_t(char*,char*);
24 typedef void dr_flushf_t(void);
25
26 struct driver { /* driver functions */
27 dr_closef_t *close; /* close device */
28 dr_clearf_t *clear; /* clear device */
29 dr_paintrf_t *paintr; /* paint rectangle */
30 dr_getcurf_t *getcur; /* get cursor position */
31 dr_comoutf_t *comout; /* command line output */
32 dr_cominf_t *comin; /* command line input */
33 dr_flushf_t *flush; /* flush output */
34 double pixaspect; /* pixel aspect ratio */
35 int xsiz, ysiz; /* device size */
36 int inpready; /* input ready on device */
37 };
38 /* magic numbers for verification */
39 #define COM_SENDM 0x6f37
40 #define COM_RECVM 0x51da
41 /* stream commands */
42 #define COM_CLEAR 0
43 #define COM_PAINTR 1
44 #define COM_GETCUR 2
45 #define COM_COMOUT 3
46 #define COM_COMIN 4
47 #define COM_FLUSH 5
48 #define NREQUESTS 6 /* number of valid requests */
49
50 extern struct device { /* interactive device */
51 char *name; /* device name */
52 char *descrip; /* description */
53 dr_initf_t *init; /* initialize device */
54 } devtable[]; /* supported devices */
55
56 extern char dev_default[]; /* default device name */
57
58 #define MB1 ('\n') /* mouse button 1 */
59 #define MB2 ('\r') /* mouse button 2 */
60 #define MB3 (' ') /* mouse button 3 */
61 #define ABORT ('C'-'@') /* abort key */
62
63 /*
64 * How to write an interactive display driver for rview.
65 * ----------------------------------------------------
66 *
67 * static struct driver dname_driver;
68 *
69 * extern dr_initf_t dname_init;
70 *
71 * extern struct driver *
72 * dname_init(
73 * char *name,
74 * char *id
75 * )
76 * {
77 * Initialize device and return pointer to driver
78 * dname_driver. Return NULL if an error occurred.
79 * The name string identifies the driver,
80 * and the id string identifies the client.
81 * A device can be open by at most one client.
82 * Be verbose in error reports; call eputs().
83 * If device has its own error output, set erract.
84 * This function then needs to be inserted into the
85 * device table in devtable.c.
86 * }
87 *
88 *
89 * static dr_closef_t dname_close;
90 *
91 * dname_driver.close = dname_close;
92 *
93 * static void
94 * dname_close(void)
95 * {
96 * Close the device. Reset error vectors.
97 * }
98 *
99 *
100 * static dr_clearf_t dname_clear;
101 *
102 * dname_driver.clear = dname_clear;
103 *
104 * static void
105 * dname_clear(
106 * int xres,
107 * int yres;
108 * )
109 * {
110 * Clear the device for xres by yres output. This call will
111 * be made prior to any output.
112 * }
113 *
114 *
115 * static dr_paintrf_t dname_paintr;
116 *
117 * dname_driver.paintr = dname_paintr;
118 *
119 * static void
120 * dname_paintr(
121 * COLOR col,
122 * int xmin,
123 * int ymin,
124 * int xmax,
125 * int ymax
126 * )
127 * {
128 * Paint a half-open rectangle from (xmin,ymin) to (xmax,ymax)
129 * with the color col.
130 * }
131 *
132 *
133 * static dr_getcurf_t dname_getcur;
134 *
135 * dname_driver.getcur = dname_getcur;
136 *
137 * static int
138 * dname_getcur(
139 * int *xp,
140 * int *yp
141 * )
142 * {
143 * Get the cursor position entered by the user via mouse,
144 * joystick, etc. Return the key hit by the user (usually
145 * MB1 or MB2). Return ABORT to cancel.
146 * Can be NULL for devices without this capability.
147 * }
148 *
149 *
150 * static dr_comoutf_t dname_comout;
151 *
152 * dname_driver.comout = dname_comout;
153 *
154 * static void
155 * dname_comout(
156 * char *out
157 * )
158 * {
159 * Print the string out on the device command line. If the
160 * string ends with '\n', the message is considered complete,
161 * and the next call can erase it.
162 * }
163 *
164 *
165 * static dr_cominf_t dname_comin;
166 *
167 * dname_driver.comin = dname_comin;
168 *
169 * static void
170 * dname_comin(
171 * char *in,
172 * char *prompt
173 * )
174 * {
175 * Print a prompt then read an edited input command line
176 * assuming the in buffer is big enough. Unless prompt is NULL,
177 * the driver may substitute its own rview command. This is
178 * the most reliable way to repaint areas of the screen.
179 * If the user enters an unrecognized control character,
180 * terminate input and return the string with only that character.
181 * The input string should not contain a newline. The routines in
182 * editline.c may be useful. Comin must work in consort with comout.
183 * }
184 *
185 *
186 * static dr_flushf_t dname_flush;
187 *
188 * dname_driver.flush = dname_flush;
189 *
190 * static void
191 * dname_flush(void)
192 * {
193 * Flush output to the display. This is guaranteed to be called
194 * frequently enough to keep the display up to date.
195 * This is an ideal time to check for device input.
196 * This function can be NULL for devices that don't need it.
197 * }
198 *
199 *
200 * dname_driver.xsiz
201 * dname_driver.ysiz
202 *
203 * The maximum allowable x and y dimensions. If any
204 * size is allowable, these should be set to MAXRES.
205 *
206 *
207 * dname_driver.inpready
208 *
209 * This variable should be made positive asynchronously
210 * when characters are ready on the input. (Often easiest
211 * to check for input during calls to paintr.)
212 */
213
214 /* defined in editline.c */
215 extern void editline(char *buf, dr_getchf_t *c_get, dr_comoutf_t *s_put);
216 extern void tocombuf(char *b, struct driver *d);
217 extern int fromcombuf(char *b, struct driver *d);
218
219 /* defined in devcomm.c */
220 extern dr_initf_t slave_init; /* XXX should probably be in a seperate file */
221 extern struct driver *comm_init(char *dname, char *id);
222
223 /* defined in colortab.c */
224 extern int new_ctab(int ncolors);
225 extern int get_pixel(COLOR col, dr_newcolrf_t *newcolr);
226 extern void make_gmap(double gam);
227 extern void set_cmap(BYTE *rmap, BYTE *gmap, BYTE *bmap);
228 extern void map_color(BYTE rgb[3], COLOR col);
229
230
231 #ifdef __cplusplus
232 }
233 #endif
234 #endif /* _RAD_DRIVER_H_ */
235