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