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