Back to index

radiance  4R0+20100331
Classes | Defines | Functions | Variables
rhdriver.h File Reference
#include "view.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  driver

Defines

#define DC_SETVIEW   0 /* set the base view */
#define DC_GETVIEW   1 /* print the current base view */
#define DC_LASTVIEW   2 /* restore previous view */
#define DC_FOCUS   3 /* view focus */
#define DC_PAUSE   4 /* pause the current calculation */
#define DC_RESUME   5 /* resume the calculation */
#define DC_REDRAW   6 /* redraw from server */
#define DC_KILL   7 /* kill rtrace process(es) */
#define DC_RESTART   8 /* restart rtrace process(es) */
#define DC_CLOBBER   9 /* clobber holodeck file */
#define DC_QUIT   10 /* quit the program */
#define DC_NCMDS   11 /* number of commands */
#define DFL(dc)   (1<<(dc))
#define CTRL(c)   ((c)-'@')
#define DV_INIT   {'\0','v','l','f','p','\r',CTRL('L'),'K','R','C','q'}
#define DC_INIT

Functions

int16 * beam_view (VIEW *vn, int hr, int vr)
void dev_open (char *id)
void dev_close (void)
void dev_clear (void)
int dev_view (register VIEW *nv)
void dev_section (char *gfn, char *pfn)
void dev_auxcom (char *cmd, char *args)
VIEWdev_auxview (int n, int hvres[2])
int dev_input (void)
void dev_value (COLR c, FVECT d, FVECT p)
int dev_flush (void)
void dev_paintr (BYTE rgb[3], int xmin, int ymin, int xmax, int ymax)
void dev_cone (BYTE rgb[3], FVECT ip, double rad)

Variables

struct driver odev
char odev_args []
int imm_mode
double eyesepdist

Class Documentation

struct driver

Definition at line 14 of file rhdriver.h.

Collaboration diagram for driver:
Class Members
dr_clearf_t * clear
dr_closef_t * close
dr_cominf_t * comin
dr_comoutf_t * comout
int firstuse
dr_flushf_t * flush
dr_getcurf_t * getcur
int hres
int ifd
int inpready
char * name
dr_paintrf_t * paintr
double pixaspect
VIEW v
int vres
int xsiz
int ysiz

Define Documentation

#define CTRL (   c)    ((c)-'@')

Definition at line 47 of file rhdriver.h.

#define DC_CLOBBER   9 /* clobber holodeck file */

Definition at line 39 of file rhdriver.h.

#define DC_FOCUS   3 /* view focus */

Definition at line 33 of file rhdriver.h.

#define DC_GETVIEW   1 /* print the current base view */

Definition at line 31 of file rhdriver.h.

#define DC_INIT
Value:
{"VIEW=","where","last","frame","pause","resume",\
                            "redraw","kill","restart","clobber","quit"}

Definition at line 51 of file rhdriver.h.

#define DC_KILL   7 /* kill rtrace process(es) */

Definition at line 37 of file rhdriver.h.

#define DC_LASTVIEW   2 /* restore previous view */

Definition at line 32 of file rhdriver.h.

#define DC_NCMDS   11 /* number of commands */

Definition at line 42 of file rhdriver.h.

#define DC_PAUSE   4 /* pause the current calculation */

Definition at line 34 of file rhdriver.h.

#define DC_QUIT   10 /* quit the program */

Definition at line 40 of file rhdriver.h.

#define DC_REDRAW   6 /* redraw from server */

Definition at line 36 of file rhdriver.h.

#define DC_RESTART   8 /* restart rtrace process(es) */

Definition at line 38 of file rhdriver.h.

#define DC_RESUME   5 /* resume the calculation */

Definition at line 35 of file rhdriver.h.

#define DC_SETVIEW   0 /* set the base view */

Definition at line 30 of file rhdriver.h.

#define DFL (   dc)    (1<<(dc))

Definition at line 45 of file rhdriver.h.

#define DV_INIT   {'\0','v','l','f','p','\r',CTRL('L'),'K','R','C','q'}

Definition at line 49 of file rhdriver.h.


Function Documentation

int16* beam_view ( VIEW vn,
int  hr,
int  vr 
)

Definition at line 169 of file rhdisp2.c.

{
       int16  *slist;
       BEAMLIST      blist;
       double eravg, d;
       register HOLO *hp;
       register int  i, n;
                                   /* compute beams for view */
       slist = viewbeams(vn, hr, vr, &blist);
       if (*slist < 0) {
              error(COMMAND, "no sections visible from this view");
              return(NULL);
       }
                                   /* sort current beam list */
       cbeamsort(1);
                                   /* add new beams to list */
       for (i = blist.nb; i--; ) {
              n = getcbeam(blist.bl[i].hd, blist.bl[i].bi);
              if (blist.bl[i].nr > cbeam[n].nr)
                     cbeam[n].nr = blist.bl[i].nr;
       }
       free((void *)blist.bl);            /* free list */
       if (MEYERNG <= FTINY)
              return(slist);
                                   /* compute average eye range */
       eravg = 0.;
       for (n = 0; slist[n] >= 0; n++) {
              hp = hdlist[slist[n]];
              eravg +=      MEYERNG/3. / VLEN(hp->wg[0]) +
                            MEYERNG/3. / VLEN(hp->wg[1]) +
                            MEYERNG/3. / VLEN(hp->wg[2]) ;
       }
       eravg /= (double)n;
                                   /* add to current eye position */
       if (cureye.rng <= FTINY) {
              VCOPY(cureye.vpt, vn->vp);
              cureye.rng = eravg;
       } else if ((d = sqrt(dist2(vn->vp,cureye.vpt))) + eravg > cureye.rng) {
              for (i = 3; i--; )
                     cureye.vpt[i] = 0.5*(cureye.vpt[i] + vn->vp[i]);
              cureye.rng = 0.5*(cureye.rng + eravg + d);
       }
       return(slist);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_auxcom ( char *  cmd,
char *  args 
)

Definition at line 298 of file rhd_glx1.c.

{
       sprintf(errmsg, "%s: unknown command", cmd);
       error(COMMAND, errmsg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

VIEW* dev_auxview ( int  n,
int  hvres[2] 
)

Definition at line 309 of file rhd_glx1.c.

{
       if (n)
              return(NULL);
       hvres[0] = odev.hres; hvres[1] = odev.vres;
       return(&odev.v);
}

Here is the caller graph for this function:

void dev_clear ( void  )

Definition at line 226 of file rhd_glx1.c.

{
       qtCompost(100);
       glClear(GL_DEPTH_BUFFER_BIT);
       rayqleft = 0;               /* hold off update */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_close ( void  )

Definition at line 208 of file rhd_glx1.c.

{
       glXMakeCurrent(ourdisplay, None, NULL);
       glXDestroyContext(ourdisplay, gctx);
       XDestroyWindow(ourdisplay, gwind);
       gwind = 0;
       XCloseDisplay(ourdisplay);
       ourdisplay = NULL;
       qtFreeLeaves();
       tmDone(tmGlobal);
       freecones();
       odev.v.type = 0;
       odev.hres = odev.vres = 0;
       odev.ifd = -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_cone ( BYTE  rgb[3],
FVECT  ip,
double  rad 
)

Definition at line 346 of file rhd_glx1.c.

{
       register int  ci, j;
       double apexh, basez;
                                   /* is window mapped? */
       if (!mapped)
              return;
                                   /* compute apex height (0. to 1.) */
       if (ip[2] > 1e6)
              apexh = 1. - 1./DEPTHFACT;
       else {
              if (ip[2] > nxtzmax)
                     nxtzmax = ip[2];
              if (ip[2] >= curzmax)
                     apexh = 1. - 1./DEPTHFACT;
              else
                     apexh = 1. - ip[2]/(curzmax*DEPTHFACT);
       }
       rad *= 1.25;                /* find conservative cone match */
       for (ci = 0; ci < MAXCONE-1; ci++)
              if (cone[ci].rad >= rad)
                     break;
                                   /* draw it */
       glColor3ub(rgb[0], rgb[1], rgb[2]);
       glBegin(GL_TRIANGLE_FAN);
       glVertex3d(ip[0], ip[1], apexh);   /* start with apex */
       basez = apexh*cone[ci].va[0][2];   /* base z's all the same */
       for (j = 0; j < cone[ci].nverts; j++)     /* draw each face */
              glVertex3d(ip[0]+cone[ci].va[j][0], ip[1]+cone[ci].va[j][1],
                            basez);
                                          /* connect last to first */
       glVertex3d(ip[0]+cone[ci].va[0][0], ip[1]+cone[ci].va[0][1], basez);
       glEnd();                           /* all done */
}

Here is the caller graph for this function:

int dev_flush ( void  )

Definition at line 336 of file rhd_glx1.c.

{
       qtUpdate();
       glFlush();
       rayqleft = RAYQLEN;
       return(XPending(ourdisplay));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int dev_input ( void  )

Definition at line 322 of file rhd_glx1.c.

{
       inpresflags = 0;

       do
              getevent();

       while (XQLength(ourdisplay) > 0);

       return(inpresflags);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_open ( char *  id)

Definition at line 108 of file rhd_glx1.c.

{
       extern char   *getenv();
       static RGBPRIMS      myprims = STDPRIMS;
       static int    atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8,
                            GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8,
                            GLX_DEPTH_SIZE,15, None};
       char   *ev;
       double gamval = GAMMA;
       RGBPRIMP      dpri = stdprims;
       XSetWindowAttributes ourwinattr;
       XWMHints      ourxwmhints;
       XSizeHints    oursizhints;
                                   /* set quadtree globals */
       qtMinNodesiz = 3;
       qtDepthEps = 0.07;
                                   /* open display server */
       ourdisplay = XOpenDisplay(NULL);
       if (ourdisplay == NULL)
              error(USER, "cannot open X-windows; DISPLAY variable set?\n");
                                   /* find a usable visual */
       ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlBest);
       if (ourvinf == NULL)
              error(USER, "no suitable visuals available");
                                   /* get a context */
       gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE);
                                   /* set gamma and tone mapping */
       if ((ev = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL
                     || (ev = getenv("DISPLAY_GAMMA")) != NULL)
              gamval = atof(ev);
       if ((ev = getenv("DISPLAY_PRIMARIES")) != NULL &&
                     sscanf(ev, "%f %f %f %f %f %f %f %f",
                            &myprims[RED][CIEX],&myprims[RED][CIEY],
                            &myprims[GRN][CIEX],&myprims[GRN][CIEY],
                            &myprims[BLU][CIEX],&myprims[BLU][CIEY],
                            &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6)
              dpri = myprims;
       tmGlobal = tmInit(mytmflags(), dpri, gamval);
       if (tmGlobal == NULL)
              error(SYSTEM, "not enough memory in dev_open");
                                   /* open window */
       ourwinattr.background_pixel = ourblack;
       ourwinattr.border_pixel = ourblack;
       ourwinattr.event_mask = ourmask;
                                   /* this is stupid */
       ourwinattr.colormap = XCreateColormap(ourdisplay, ourroot,
                            ourvinf->visual, AllocNone);
       gwind = XCreateWindow(ourdisplay, ourroot, 0, 0,
              DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH,
              DisplayHeight(ourdisplay,ourscreen)-2*BORWIDTH,
              BORWIDTH, ourvinf->depth, InputOutput, ourvinf->visual,
              CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &ourwinattr);
       if (gwind == 0)
              error(SYSTEM, "cannot create window\n");
       XStoreName(ourdisplay, gwind, id);
                                   /* set window manager hints */
       ourxwmhints.flags = InputHint|IconPixmapHint;
       ourxwmhints.input = True;
       ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay,
                     gwind, x11icon_bits, x11icon_width, x11icon_height);
       XSetWMHints(ourdisplay, gwind, &ourxwmhints);
       oursizhints.min_width = MINWIDTH;
       oursizhints.min_height = MINHEIGHT;
       oursizhints.flags = PMinSize;
       XSetNormalHints(ourdisplay, gwind, &oursizhints);
                                   /* set GLX context */
       glXMakeCurrent(ourdisplay, gwind, gctx);
       glEnable(GL_DEPTH_TEST);
       glDepthFunc(GL_LEQUAL);
       glShadeModel(GL_FLAT);
       glDisable(GL_DITHER);
       glDisable(GL_CULL_FACE);
       glMatrixMode(GL_PROJECTION);
       glOrtho(0., 1., 0., 1., -.01, 1.01);
       glTranslated(0., 0., -1.01);
                                   /* figure out sensible view */
       pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) /
                     DisplayWidth(ourdisplay, ourscreen);
       pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) /
                     DisplayHeight(ourdisplay, ourscreen);
       odev.v = stdview;
       odev.v.type = VT_PER;
                                   /* map the window */
       XMapWindow(ourdisplay, gwind);
       dev_input();                /* sets size and view angles */
                                   /* allocate our leaf pile */
       if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) *
                     DisplayHeight(ourdisplay,ourscreen) * 3 /
                     (qtMinNodesiz*qtMinNodesiz*2)))
              error(SYSTEM, "insufficient memory for value storage");
       odev.name = id;
       odev.ifd = ConnectionNumber(ourdisplay);
                                   /* initialize cone array */
       initcones();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_paintr ( BYTE  rgb[3],
int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Definition at line 347 of file rhd_x11.c.

{
       unsigned long  pixel;

       if (!mapped)
              return;
       if (ncolors > 0)
              pixel = pixval[get_pixel(rgb, xnewcolr)];
       else
              pixel = true_pixel(rgb);
       XSetForeground(ourdisplay, ourgc, pixel);
       XFillRectangle(ourdisplay, gwind, 
              ourgc, xmin, odev.vres-ymax, xmax-xmin, ymax-ymin);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_section ( char *  gfn,
char *  pfn 
)

Definition at line 288 of file rhd_glx1.c.

{
       /* unimplemented */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void dev_value ( COLR  c,
FVECT  d,
FVECT  p 
)

Definition at line 460 of file rhd_ogl.c.

{
#ifdef DOBJ
       if (dobj_lightsamp != NULL) {      /* in light source sampling */
              (*dobj_lightsamp)(c, d, p);
              return;
       }
#endif
       odSample(c, d, p);          /* add to display representation */
       if (!--rayqleft)
              dev_flush();         /* flush output */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int dev_view ( register VIEW nv)

Definition at line 235 of file rhd_glx1.c.

{
       if (nv->type == VT_PAR ||          /* check view legality */
                     nv->horiz > 160. || nv->vert > 160.) {
              error(COMMAND, "illegal view type/angle");
              nv->type = odev.v.type;
              nv->horiz = odev.v.horiz;
              nv->vert = odev.v.vert;
              return(0);
       }
       if (nv->vfore > FTINY) {
              error(COMMAND, "cannot handle fore clipping");
              nv->vfore = 0.;
              return(0);
       }
       if (nv != &odev.v) {
              if (!FEQ(nv->horiz,odev.v.horiz) ||       /* resize window? */
                            !FEQ(nv->vert,odev.v.vert)) {
                     int    dw = DisplayWidth(ourdisplay,ourscreen);
                     int    dh = DisplayHeight(ourdisplay,ourscreen);

                     dw -= 25;     /* for window frame */
                     dh -= 50;
                     odev.hres = 2.*VIEWDIST/pwidth *
                                   tan(PI/180./2.*nv->horiz);
                     odev.vres = 2.*VIEWDIST/pheight *
                                   tan(PI/180./2.*nv->vert);
                     if (odev.hres > dw) {
                            odev.vres = dw * odev.vres / odev.hres;
                            odev.hres = dw;
                     }
                     if (odev.vres > dh) {
                            odev.hres = dh * odev.hres / odev.vres;
                            odev.vres = dh;
                     }
                     XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres);
                     dev_input();  /* get resize event */
              }
              odev.v = *nv;
       }
       if (nxtzmax > FTINY) {
              curzmax = nxtzmax;
              nxtzmax = 0.;
       }
       glClear(GL_DEPTH_BUFFER_BIT);
       qtReplant();
       return(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double eyesepdist

Definition at line 44 of file rhdisp.c.

int imm_mode

Definition at line 40 of file rhdisp.c.

struct driver odev
char odev_args[]

Definition at line 66 of file rhd_glx1.c.