ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/driver.h
(Generate patch)

Comparing ray/src/rt/driver.h (file contents):
Revision 1.5 by greg, Tue Jan 30 11:37:34 1990 UTC vs.
Revision 2.10 by greg, Fri May 20 02:06:39 2011 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   *  driver.h - header file for interactive device drivers.
7 *
8 *     2/2/87
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 <        int  (*close)();                        /* close device */
28 <        int  (*clear)();                        /* clear device */
29 <        int  (*paintr)();                       /* paint rectangle */
30 <        int  (*getcur)();                       /* get cursor position */
31 <        int  (*comout)();                       /* command line output */
32 <        int  (*comin)();                        /* command line input */
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   };
22
23 extern int  stderr_v();                 /* error vectors */
24 extern int  (*wrnvec)(), (*errvec)(), (*cmdvec)();
25
26 extern struct driver  *comm_init();     /* stream interface */
38                                          /* magic numbers for verification */
39   #define COM_SENDM               0x6f37
40   #define COM_RECVM               0x51da
# Line 33 | Line 44 | extern struct driver  *comm_init();    /* stream interfac
44   #define COM_GETCUR              2
45   #define COM_COMOUT              3
46   #define COM_COMIN               4
47 < #define NREQUESTS               5       /* number of valid requests */
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 <        struct driver  *(*init)();              /* initialize device */
54 < }  devtable[];                          /* supported devices */
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 < *  struct driver *
65 < *  dname_init(name, id)
66 < *  char  *name, *id;
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 < *      functions.  Returns NULL if an error occurred.
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 stderr_v().
83 < *      If device has its own error output, set errvec,
84 < *      cmdvec and wrnvec.
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 < *  (*dev->close)()
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 < *  (*dev->clear)(xres, yres)
99 < *  int  xres, yres;
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 < *  (*dev->paintr)(col, xmin, ymin, xmax, ymax)
114 < *  COLOR  col;
115 < *  int  xmin, ymin, xmax, ymax;
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.  Can call repaint() if necessary.
129 > *      with the color col.
130   *  }
131 < *  (*dev->getcur)(xp, yp)
132 < *  int  *xp, *yp;
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 < *  (*dev->comout)(out)
149 < *  char  *out;
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 < *  (*dev->comin)(in, prompt)
164 < *  char  *in, *prompt;
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 is entered,
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 < *  xsiz, ysiz
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 < *  inpready
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(uby8 *rmap, uby8 *gmap, uby8 *bmap);
228 + extern void     map_color(uby8 rgb[3], COLOR col);
229 +
230 +
231 + #ifdef __cplusplus
232 + }
233 + #endif
234 + #endif /* _RAD_DRIVER_H_ */
235 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines