| 1 |
gregl |
3.1 |
/* Copyright (c) 1997 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; /* preferred view parameters */ |
| 14 |
|
|
int hres, vres; /* device resolution */ |
| 15 |
|
|
int ifd; /* input file descriptor (for select) */ |
| 16 |
|
|
} odev; /* our open device */ |
| 17 |
|
|
|
| 18 |
gregl |
3.8 |
/* user commands */ |
| 19 |
|
|
#define DC_SETVIEW 0 /* set the view */ |
| 20 |
|
|
#define DC_GETVIEW 1 /* print the current view */ |
| 21 |
|
|
#define DC_LASTVIEW 2 /* restore previous view */ |
| 22 |
|
|
#define DC_PAUSE 3 /* pause the current calculation */ |
| 23 |
|
|
#define DC_RESUME 4 /* resume the calculation */ |
| 24 |
|
|
#define DC_REDRAW 5 /* redraw from server */ |
| 25 |
|
|
#define DC_QUIT 6 /* quit the program */ |
| 26 |
gregl |
3.1 |
|
| 27 |
gregl |
3.8 |
#define DC_NCMDS 7 /* number of commands */ |
| 28 |
gregl |
3.1 |
|
| 29 |
gregl |
3.8 |
/* dev_input() returns flags from above */ |
| 30 |
|
|
#define DFL(dc) (1<<(dc)) |
| 31 |
|
|
|
| 32 |
|
|
#define CTRL(c) ((c)-'@') |
| 33 |
|
|
/* commands entered in display window */ |
| 34 |
|
|
#define DV_INIT {'\0','v','l','p','\r',CTRL('R'),'q'} |
| 35 |
|
|
/* commands entered on stdin */ |
| 36 |
|
|
#define DC_INIT {"VIEW=","where","last","pause","resume","redraw",\ |
| 37 |
|
|
"quit"} |
| 38 |
|
|
|
| 39 |
|
|
|
| 40 |
gregl |
3.1 |
/************************************************************************ |
| 41 |
|
|
* Driver routines (all are required): |
| 42 |
|
|
|
| 43 |
|
|
|
| 44 |
|
|
void |
| 45 |
|
|
dev_open(nm) : prepare the device |
| 46 |
|
|
char *nm; : appropriate title bar annotation |
| 47 |
|
|
|
| 48 |
|
|
Sets fields of odev structure and prepares the display for i/o. |
| 49 |
|
|
The view type, horizontal and vertical view angles and other default |
| 50 |
|
|
parameters in odev.v should also be assigned. |
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
gregl |
3.7 |
int |
| 54 |
gregl |
3.1 |
dev_view(nv) : set display view parameters |
| 55 |
|
|
VIEW *nv; : the new view |
| 56 |
|
|
|
| 57 |
|
|
Updates the display for the given view change. |
| 58 |
|
|
Look for nv==&odev.v when making view current after dev_input() |
| 59 |
gregl |
3.7 |
returns DEV_NEWVIEW flag. Return 1 on success, or 0 if the |
| 60 |
|
|
new view would conflict with device requirements. In the latter |
| 61 |
|
|
case, reset parameters in nv to make it more agreeable, calling |
| 62 |
|
|
error(COMMAND, "appropriate user warning"). |
| 63 |
gregl |
3.1 |
|
| 64 |
|
|
|
| 65 |
|
|
void |
| 66 |
gregl |
3.5 |
dev_value(c, p, v) : register new point of light |
| 67 |
gregl |
3.1 |
COLR c; : pixel color (RGBE) |
| 68 |
|
|
FVECT p; : world intersection point |
| 69 |
gregl |
3.5 |
FVECT v; : ray direction vector |
| 70 |
gregl |
3.1 |
|
| 71 |
|
|
Add the given color point to the display output queue. |
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
int |
| 75 |
|
|
dev_flush() : flush the output and prepare for select call |
| 76 |
|
|
|
| 77 |
|
|
Updates display, taking any pending action required before select(2) call. |
| 78 |
|
|
Returns non-zero if there is device input available. |
| 79 |
|
|
|
| 80 |
|
|
|
| 81 |
|
|
int |
| 82 |
|
|
dev_input() : process pending display input |
| 83 |
|
|
|
| 84 |
|
|
Called when odev struct file descriptor shows input is ready. |
| 85 |
|
|
Returns flags indicating actions to take in the control process. |
| 86 |
gregl |
3.8 |
If the DC_VIEW or DC_RESIZE flag is returned, the odev |
| 87 |
gregl |
3.1 |
structure must be updated beforehand. |
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
void |
| 91 |
|
|
dev_close() : close the display |
| 92 |
|
|
|
| 93 |
|
|
Close the display device and free up resources in preparation for exit. |
| 94 |
|
|
Set odev.v.type=0 and odev.hres=odev.vres=0 when done. |
| 95 |
|
|
|
| 96 |
|
|
|
| 97 |
|
|
************************************************************************/ |