1 |
/* RCSid: $Id: rhdriver.h,v 3.23 2003/07/14 22:24:00 schorsch Exp $ */ |
2 |
/* |
3 |
* Header file for holodeck device driver routines. |
4 |
*/ |
5 |
#ifndef _RAD_RHDRIVER_H_ |
6 |
#define _RAD_RHDRIVER_H_ |
7 |
|
8 |
#include "view.h" |
9 |
|
10 |
#ifdef __cplusplus |
11 |
extern "C" { |
12 |
#endif |
13 |
|
14 |
extern struct driver { |
15 |
char *name; /* holodeck name or title */ |
16 |
VIEW v; /* base view parameters */ |
17 |
int hres, vres; /* base view resolution */ |
18 |
int ifd; /* input file descriptor (for select) */ |
19 |
int firstuse; /* non-zero if driver can't recycle samples */ |
20 |
int inpready; /* number of unprocessed input events */ |
21 |
} odev; /* our open device */ |
22 |
|
23 |
extern char odev_args[]; /* command arguments, if any */ |
24 |
|
25 |
extern int imm_mode; /* bundles are being delivered immediately */ |
26 |
|
27 |
extern double eyesepdist; /* world eye separation distance */ |
28 |
|
29 |
/* user commands */ |
30 |
#define DC_SETVIEW 0 /* set the base view */ |
31 |
#define DC_GETVIEW 1 /* print the current base view */ |
32 |
#define DC_LASTVIEW 2 /* restore previous view */ |
33 |
#define DC_FOCUS 3 /* view focus */ |
34 |
#define DC_PAUSE 4 /* pause the current calculation */ |
35 |
#define DC_RESUME 5 /* resume the calculation */ |
36 |
#define DC_REDRAW 6 /* redraw from server */ |
37 |
#define DC_KILL 7 /* kill rtrace process(es) */ |
38 |
#define DC_RESTART 8 /* restart rtrace process(es) */ |
39 |
#define DC_CLOBBER 9 /* clobber holodeck file */ |
40 |
#define DC_QUIT 10 /* quit the program */ |
41 |
|
42 |
#define DC_NCMDS 11 /* number of commands */ |
43 |
|
44 |
/* dev_input() returns flags from above */ |
45 |
#define DFL(dc) (1<<(dc)) |
46 |
|
47 |
#define CTRL(c) ((c)-'@') |
48 |
/* commands entered in display window */ |
49 |
#define DV_INIT {'\0','v','l','f','p','\r',CTRL('L'),'K','R','C','q'} |
50 |
/* commands entered on stdin */ |
51 |
#define DC_INIT {"VIEW=","where","last","frame","pause","resume",\ |
52 |
"redraw","kill","restart","clobber","quit"} |
53 |
|
54 |
|
55 |
/************************************************************************ |
56 |
* Driver routines (all are required): |
57 |
|
58 |
|
59 |
void |
60 |
dev_open(nm) : prepare the device |
61 |
char *nm; : appropriate title bar annotation |
62 |
|
63 |
Sets fields of odev structure and prepares the display for i/o. |
64 |
The base view type, horizontal and vertical view angles and other |
65 |
default parameters in odev.v should also be assigned. |
66 |
|
67 |
|
68 |
int |
69 |
dev_view(nv) : set base view parameters |
70 |
VIEW *nv; : the new view |
71 |
|
72 |
Updates the display for the given base view change. |
73 |
Look for nv==&odev.v when making view current after dev_input() |
74 |
returns DEV_NEWVIEW flag. Return 1 on success, or 0 if the |
75 |
new view would conflict with device requirements. In the latter |
76 |
case, reset parameters in nv to make it more agreeable, calling |
77 |
error(COMMAND, "appropriate user warning"). |
78 |
|
79 |
|
80 |
void |
81 |
dev_clear() : clear device memory |
82 |
|
83 |
Clear the device memory in preparation for fresh data. Clearing |
84 |
the screen is optional. |
85 |
|
86 |
|
87 |
void |
88 |
dev_value(c, d, p) : register new point of light |
89 |
COLR c; : pixel color (RGBE) |
90 |
FVECT d; : ray direction vector |
91 |
FVECT p; : world intersection point |
92 |
|
93 |
Add the given color point to the display output queue. If imm_mode is |
94 |
non-zero, then values are being sent in rapid succession. If p is NULL, |
95 |
then the point is at infinity. |
96 |
|
97 |
|
98 |
int |
99 |
dev_flush() : flush the output and prepare for select call |
100 |
|
101 |
Updates display, taking any pending action required before select(2) call. |
102 |
Returns non-zero if there is device input available, setting odev.inpready. |
103 |
|
104 |
|
105 |
int |
106 |
dev_input() : process pending display input |
107 |
|
108 |
Called when odev struct file descriptor shows input is ready. |
109 |
Returns flags indicating actions to take in the control process. |
110 |
If the DC_VIEW or DC_RESIZE flag is returned, the odev |
111 |
structure must be updated beforehand. If the DC_FOCUS |
112 |
flag is set, then odev_args contains the frame dimensions. |
113 |
No events shall remain when this function returns, |
114 |
and odev.inpready will therefore be 0. |
115 |
|
116 |
void |
117 |
dev_auxcom(cmd, args) : process auxiliary command |
118 |
char *cmd, *args; : command name and argument string |
119 |
|
120 |
Execute an auxiliary command (not one of those listed at the head of |
121 |
this file). The cmd argument points to the command name itself, and |
122 |
the args argument points to a string with the rest of the input line. |
123 |
If the command isn't known or there ARE no auxiliary commands, print |
124 |
an appropriate COMMAND error message and return. |
125 |
|
126 |
|
127 |
VIEW * |
128 |
dev_auxview(n, hv) : return nth auxiliary view |
129 |
int n; : auxiliary view number |
130 |
int hv[2]; : returned horiz. and vert. image resolution |
131 |
|
132 |
Return the nth auxiliary view associated with the current base view. |
133 |
The hv entries are assigned the horizontal and vertical view resolution, |
134 |
respectively. Function returns NULL if there are no more auxiliary |
135 |
views. The zeroeth auxiliary view is the base view itself. |
136 |
|
137 |
|
138 |
void |
139 |
dev_section(gf, pf) : add geometry and ports for rendering |
140 |
char *gf; : geometry file name |
141 |
char *pf; : portal file name(s) |
142 |
|
143 |
Add the given geometry file to the list of geometry to render for |
144 |
intermediate views if direct geometry rendering is available. The |
145 |
second argument gives the name(s) of any portal geometry files |
146 |
associated with this section. Multiple portal file names are separated |
147 |
by spaces. A single octree file will be given for the geometry, ending |
148 |
in the ".oct" suffix. Portal files will be given as zero or more |
149 |
Radiance scene description file names. If no portals are given for |
150 |
this section, the string may be NULL. The character strings are |
151 |
guaranteed to be static (or permanently allocated) such that they may |
152 |
be safely stored as a pointer. The same pointers or file lists may be |
153 |
(and often are) given repeatedly. If a given geometry file does not |
154 |
exist, the call should be silently ignored. If gf is NULL, then the |
155 |
last section has been given, and the display can be updated with the |
156 |
new information. |
157 |
|
158 |
|
159 |
void |
160 |
dev_close() : close the display |
161 |
|
162 |
Close the display device and free up resources in preparation for exit. |
163 |
Set odev.v.type=0 and odev.hres=odev.vres=0 when done. |
164 |
|
165 |
|
166 |
************************************************************************/ |
167 |
|
168 |
|
169 |
/* |
170 |
extern VIEW *dev_auxview(); |
171 |
*/ |
172 |
extern int16 *beam_view(VIEW *vn, int hr, int vr); |
173 |
|
174 |
|
175 |
extern void dev_open(char *id); |
176 |
extern void dev_close(void); |
177 |
extern void dev_clear(void); |
178 |
extern int dev_view(register VIEW *nv); |
179 |
//extern void dev_section(char *ofn); /* XXX */ |
180 |
extern void dev_auxcom(char *cmd, char *args); |
181 |
extern VIEW *dev_auxview(int n, int hvres[2]); |
182 |
extern int dev_input(void); |
183 |
extern void dev_value(COLR c, FVECT d, FVECT p); |
184 |
extern int dev_flush(void); |
185 |
extern void dev_paintr(BYTE rgb[3], int xmin, int ymin, int xmax, int ymax); |
186 |
extern void dev_cone(BYTE rgb[3], FVECT ip, double rad); |
187 |
|
188 |
#ifdef __cplusplus |
189 |
} |
190 |
#endif |
191 |
#endif /* _RAD_RHDRIVER_H_ */ |
192 |
|