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

# User Rev Content
1 greg 2.5 /* RCSid $Id$ */
2 greg 1.1 /*
3     * driver.h - header file for interactive device drivers.
4 greg 2.4 */
5    
6 greg 2.5 #include "copyright.h"
7 greg 1.1
8     struct driver { /* driver functions */
9 greg 2.4 void (*close)(); /* close device */
10     void (*clear)(); /* clear device */
11     void (*paintr)(); /* paint rectangle */
12 greg 1.1 int (*getcur)(); /* get cursor position */
13 greg 2.4 void (*comout)(); /* command line output */
14     void (*comin)(); /* command line input */
15     void (*flush)(); /* flush output */
16 greg 1.4 double pixaspect; /* pixel aspect ratio */
17 greg 1.1 int xsiz, ysiz; /* device size */
18     int inpready; /* input ready on device */
19     };
20 greg 1.3 /* magic numbers for verification */
21     #define COM_SENDM 0x6f37
22     #define COM_RECVM 0x51da
23 greg 1.1 /* 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 greg 1.6 #define COM_FLUSH 5
30     #define NREQUESTS 6 /* number of valid requests */
31 greg 1.1
32 greg 1.4 extern struct device { /* interactive device */
33 greg 1.1 char *name; /* device name */
34     char *descrip; /* description */
35     struct driver *(*init)(); /* initialize device */
36 greg 1.4 } devtable[]; /* supported devices */
37 greg 1.1
38 greg 1.8 extern char dev_default[]; /* default device name */
39    
40 greg 1.1 #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 greg 1.3 * dname_init(name, id)
48     * char *name, *id;
49 greg 1.1 * {
50     * Initialize device and return pointer to driver
51     * functions. Returns NULL if an error occurred.
52 greg 1.3 * The name string identifies the driver,
53     * and the id string identifies the client.
54 greg 1.1 * A device can be open by at most one client.
55 gregl 2.3 * Be verbose in error reports; call eputs().
56     * If device has its own error output, set erract.
57 greg 1.1 * }
58     * (*dev->close)()
59     * {
60 greg 1.2 * Close the device. Reset error vectors.
61 greg 1.1 * }
62     * (*dev->clear)(xres, yres)
63     * int xres, yres;
64     * {
65 greg 1.2 * Clear the device for xres by yres output. This call will
66 greg 1.1 * 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 greg 1.6 * with the color col.
74 greg 1.1 * }
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 greg 1.5 * (*dev->comin)(in, prompt)
91     * char *in, *prompt;
92 greg 1.1 * {
93 greg 1.5 * 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 greg 1.7 * If the user enters an unrecognized control character,
98 greg 1.5 * 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 greg 1.6 * }
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 greg 1.1 * }
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 greg 1.2 * 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 greg 1.1 */
117 greg 2.4
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