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 2.8 by schorsch, Wed Aug 20 10:00:09 2003 UTC vs.
Revision 2.9 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 11 | Line 11
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 <        void  (*close)(void);                   /* close device */
28 <        void  (*clear)(int, int);                       /* clear device */
29 <        void  (*paintr)(COLOR  col, int  xmin, int ymin, int xmax, int ymax);                   /* paint rectangle */
30 <        int  (*getcur)(int*,int*);                      /* get cursor position */
31 <        void  (*comout)(char*);                 /* command line output */
32 <        void  (*comin)();                       /* command line input */
33 <        void  (*flush)();                       /* flush output */
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 */
# Line 38 | Line 50 | struct driver {                                /* driver functions */
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  
# Line 49 | Line 61 | extern char  dev_default[];            /* default device name */
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 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.
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,
# Line 105 | Line 181 | extern char  dev_default[];            /* default device name */
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 < *  (*dev->flush)()
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 < *  xsiz, ysiz
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, int (*c_get)(), void (*s_put)());
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 struct driver    *slave_init(char *dname, char *id);
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, void (*set_pixel)());
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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines