ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
Revision: 2.6
Committed: Sat Jun 7 00:54:58 2003 UTC (20 years, 10 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 2.5: +12 -15 lines
Log Message:
Instrumented headers against multiple inclusion and for use from C++.
Removed NOPROTO sections.

File Contents

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