Back to index

radiance  4R0+20100331
rhdriver.h
Go to the documentation of this file.
00001 /* RCSid: $Id: rhdriver.h,v 3.25 2006/06/07 17:52:04 schorsch Exp $ */
00002 /*
00003  * Header file for holodeck device driver routines.
00004  */
00005 #ifndef _RAD_RHDRIVER_H_
00006 #define _RAD_RHDRIVER_H_
00007 
00008 #include "view.h"
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 extern struct driver {
00015        char   *name;        /* holodeck name or title */
00016        VIEW   v;            /* base view parameters */
00017        int    hres, vres;   /* base view resolution */
00018        int    ifd;          /* input file descriptor (for select) */
00019        int    firstuse;     /* non-zero if driver can't recycle samples */
00020        int    inpready;     /* number of unprocessed input events */
00021 } odev;                     /* our open device */
00022 
00023 extern char   odev_args[];  /* command arguments, if any */
00024 
00025 extern int    imm_mode;     /* bundles are being delivered immediately */
00026 
00027 extern double eyesepdist;   /* world eye separation distance */
00028 
00029                             /* user commands */
00030 #define       DC_SETVIEW    0             /* set the base view */
00031 #define       DC_GETVIEW    1             /* print the current base view */
00032 #define       DC_LASTVIEW   2             /* restore previous view */
00033 #define DC_FOCUS     3             /* view focus */
00034 #define       DC_PAUSE      4             /* pause the current calculation */
00035 #define       DC_RESUME     5             /* resume the calculation */
00036 #define       DC_REDRAW     6             /* redraw from server */
00037 #define       DC_KILL              7             /* kill rtrace process(es) */
00038 #define       DC_RESTART    8             /* restart rtrace process(es) */
00039 #define DC_CLOBBER   9             /* clobber holodeck file */
00040 #define       DC_QUIT              10            /* quit the program */
00041 
00042 #define       DC_NCMDS      11            /* number of commands */
00043 
00044                             /* dev_input() returns flags from above */
00045 #define DFL(dc)             (1<<(dc))
00046 
00047 #define       CTRL(c)              ((c)-'@')
00048                             /* commands entered in display window */
00049 #define DV_INIT             {'\0','v','l','f','p','\r',CTRL('L'),'K','R','C','q'}
00050                             /* commands entered on stdin */
00051 #define       DC_INIT              {"VIEW=","where","last","frame","pause","resume",\
00052                             "redraw","kill","restart","clobber","quit"}
00053 
00054 
00055 /************************************************************************
00056  * Driver routines (all are required):
00057 
00058 
00059 void
00060 dev_open(nm)         : prepare the device
00061 char   *nm;          : appropriate title bar annotation
00062 
00063 Sets fields of odev structure and prepares the display for i/o.
00064 The base view type, horizontal and vertical view angles and other
00065 default parameters in odev.v should also be assigned.
00066 
00067 
00068 int
00069 dev_view(nv)         : set base view parameters
00070 VIEW   *nv;          : the new view
00071 
00072 Updates the display for the given base view change.
00073 Look for nv==&odev.v when making view current after dev_input()
00074 returns DEV_NEWVIEW flag.  Return 1 on success, or 0 if the
00075 new view would conflict with device requirements.  In the latter
00076 case, reset parameters in nv to make it more agreeable, calling
00077 error(COMMAND, "appropriate user warning").
00078 
00079 
00080 void
00081 dev_clear()          : clear device memory
00082 
00083 Clear the device memory in preparation for fresh data.  Clearing
00084 the screen is optional.
00085 
00086 
00087 void
00088 dev_value(c, d, p)   : register new point of light
00089 COLR   c;            : pixel color (RGBE)
00090 FVECT  d;            : ray direction vector
00091 FVECT  p;            : world intersection point
00092 
00093 Add the given color point to the display output queue.  If imm_mode is
00094 non-zero, then values are being sent in rapid succession.  If p is NULL,
00095 then the point is at infinity.
00096 
00097 
00098 int
00099 dev_flush()          : flush the output and prepare for select call
00100 
00101 Updates display, taking any pending action required before select(2) call.
00102 Returns non-zero if there is device input available, setting odev.inpready.
00103 
00104 
00105 int
00106 dev_input()          : process pending display input
00107 
00108 Called when odev struct file descriptor shows input is ready.
00109 Returns flags indicating actions to take in the control process.
00110 If the DC_VIEW or DC_RESIZE flag is returned, the odev
00111 structure must be updated beforehand.  If the DC_FOCUS
00112 flag is set, then odev_args contains the frame dimensions.
00113 No events shall remain when this function returns,
00114 and odev.inpready will therefore be 0.
00115 
00116 void
00117 dev_auxcom(cmd, args)       : process auxiliary command
00118 char   *cmd, *args;  : command name and argument string
00119 
00120 Execute an auxiliary command (not one of those listed at the head of
00121 this file).  The cmd argument points to the command name itself, and
00122 the args argument points to a string with the rest of the input line.
00123 If the command isn't known or there ARE no auxiliary commands, print
00124 an appropriate COMMAND error message and return.
00125 
00126 
00127 VIEW *
00128 dev_auxview(n, hv)   : return nth auxiliary view
00129 int    n;            : auxiliary view number
00130 int    hv[2];        : returned horiz. and vert. image resolution
00131 
00132 Return the nth auxiliary view associated with the current base view.
00133 The hv entries are assigned the horizontal and vertical view resolution,
00134 respectively.  Function returns NULL if there are no more auxiliary
00135 views.  The zeroeth auxiliary view is the base view itself.
00136 
00137 
00138 void
00139 dev_section(gf, pf)  : add geometry and ports for rendering
00140 char   *gf;          : geometry file name
00141 char   *pf;          : portal file name(s)
00142 
00143 Add the given geometry file to the list of geometry to render for
00144 intermediate views if direct geometry rendering is available.  The
00145 second argument gives the name(s) of any portal geometry files
00146 associated with this section.  Multiple portal file names are separated
00147 by spaces.  A single octree file will be given for the geometry, ending
00148 in the ".oct" suffix.  Portal files will be given as zero or more
00149 Radiance scene description file names.  If no portals are given for
00150 this section, the string may be NULL.  The character strings are
00151 guaranteed to be static (or permanently allocated) such that they may
00152 be safely stored as a pointer.  The same pointers or file lists may be
00153 (and often are) given repeatedly.  If a given geometry file does not
00154 exist, the call should be silently ignored.  If gf is NULL, then the
00155 last section has been given, and the display can be updated with the
00156 new information.
00157 
00158 
00159 void
00160 dev_close()          : close the display
00161 
00162 Close the display device and free up resources in preparation for exit.
00163 Set odev.v.type=0 and odev.hres=odev.vres=0 when done.
00164 
00165 
00166  ************************************************************************/
00167 
00168 
00169 /*
00170 extern VIEW   *dev_auxview();
00171 */
00172 extern int16  *beam_view(VIEW *vn, int hr, int vr);
00173 
00174 
00175 extern void dev_open(char  *id);
00176 extern void dev_close(void);
00177 extern void dev_clear(void);
00178 extern int dev_view(register VIEW *nv);
00179 extern void dev_section(char *gfn, char *pfn);
00180 extern void dev_auxcom(char *cmd, char *args);
00181 extern VIEW *dev_auxview(int n, int hvres[2]);
00182 extern int dev_input(void);
00183 extern void dev_value(COLR c, FVECT d, FVECT p);
00184 extern int dev_flush(void);
00185 extern void dev_paintr(BYTE rgb[3], int xmin, int ymin, int xmax, int ymax);
00186 extern void dev_cone(BYTE rgb[3], FVECT ip, double rad);
00187 
00188 #ifdef __cplusplus
00189 }
00190 #endif
00191 #endif /* _RAD_RHDRIVER_H_ */
00192