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