ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_glx.c
(Generate patch)

Comparing ray/src/hd/rhd_glx.c (file contents):
Revision 3.5 by gregl, Fri Dec 26 14:46:21 1997 UTC vs.
Revision 3.18 by gwlarson, Wed Jun 17 15:44:07 1998 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1997 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1998 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ SGI";
16  
17   #include  "x11icon.h"
18  
19 + #ifndef RAYQLEN
20 + #define RAYQLEN         50000           /* max. rays to queue before flush */
21 + #endif
22 +
23   #ifndef FEQ
24   #define FEQ(a,b)        ((a)-(b) <= FTINY && (a)-(b) >= -FTINY)
25   #endif
# Line 24 | Line 28 | static char SCCSid[] = "$SunId$ SGI";
28   #define MAXCONE         16              /* number of different cone sizes */
29   #endif
30   #ifndef MAXVERT
31 < #define MAXVERT         32              /* maximum number of cone vertices */
31 > #define MAXVERT         64              /* maximum number of cone vertices */
32   #endif
33   #ifndef MINVERT
34   #define MINVERT         4               /* minimum number of cone vertices */
# Line 90 | Line 94 | dev_open(id)                   /* initialize X11 driver */
94   char  *id;
95   {
96          extern char     *getenv();
97 +        static RGBPRIMS myprims = STDPRIMS;
98          static int      atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8,
99                                  GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8,
100                                  GLX_DEPTH_SIZE,15, None};
101 <        char    *gv;
101 >        char    *ev;
102          double  gamval = GAMMA;
103 +        RGBPRIMP        dpri = stdprims;
104          XSetWindowAttributes    ourwinattr;
105          XWMHints        ourxwmhints;
106          XSizeHints      oursizhints;
107                                          /* set quadtree globals */
108          qtMinNodesiz = 3;
109 +        qtDepthEps = 0.07;
110                                          /* open display server */
111          ourdisplay = XOpenDisplay(NULL);
112          if (ourdisplay == NULL)
# Line 111 | Line 118 | char  *id;
118                                          /* get a context */
119          gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE);
120                                          /* set gamma and tone mapping */
121 <        if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL
122 <                        || (gv = getenv("DISPLAY_GAMMA")) != NULL)
123 <                gamval = atof(gv);
124 <        if (tmInit(mytmflags(), stdprims, gamval) == NULL)
121 >        if ((ev = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL
122 >                        || (ev = getenv("DISPLAY_GAMMA")) != NULL)
123 >                gamval = atof(ev);
124 >        if ((ev = getenv("DISPLAY_PRIMARIES")) != NULL &&
125 >                        sscanf(ev, "%f %f %f %f %f %f %f %f",
126 >                                &myprims[RED][CIEX],&myprims[RED][CIEY],
127 >                                &myprims[GRN][CIEX],&myprims[GRN][CIEY],
128 >                                &myprims[BLU][CIEX],&myprims[BLU][CIEY],
129 >                                &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6)
130 >                dpri = myprims;
131 >        if (tmInit(mytmflags(), dpri, gamval) == NULL)
132                  error(SYSTEM, "not enough memory in dev_open");
133                                          /* open window */
134          ourwinattr.background_pixel = ourblack;
# Line 161 | Line 175 | char  *id;
175                                          /* map the window */
176          XMapWindow(ourdisplay, gwind);
177          dev_input();                    /* sets size and view angles */
164        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
178                                          /* allocate our leaf pile */
179 <        if (!qtAllocLeaves(2 * DisplayWidth(ourdisplay,ourscreen) *
180 <                        DisplayHeight(ourdisplay,ourscreen) /
181 <                        (qtMinNodesiz*qtMinNodesiz)))
179 >        if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) *
180 >                        DisplayHeight(ourdisplay,ourscreen) * 3 /
181 >                        (qtMinNodesiz*qtMinNodesiz*2)))
182                  error(SYSTEM, "insufficient memory for value storage");
183          odev.name = id;
184          odev.ifd = ConnectionNumber(ourdisplay);
# Line 191 | Line 204 | dev_close()                    /* close our display and free resources
204   }
205  
206  
207 + dev_clear()                     /* clear our quadtree */
208 + {
209 +        qtCompost(100);
210 +        glClear(GL_DEPTH_BUFFER_BIT);
211 +        rayqleft = 0;                   /* hold off update */
212 + }
213 +
214 +
215   int
216   dev_view(nv)                    /* assign new driver view */
217   register VIEW   *nv;
# Line 243 | Line 264 | register VIEW  *nv;
264   }
265  
266  
267 + dev_auxcom(cmd, args)           /* process an auxiliary command */
268 + char    *cmd, *args;
269 + {
270 +        sprintf(errmsg, "%s: unknown command", cmd);
271 +        error(COMMAND, errmsg);
272 + }
273 +
274 +
275 + VIEW *
276 + dev_auxview(n, hvres)           /* return nth auxiliary view */
277 + int     n;
278 + int     hvres[2];
279 + {
280 +        if (n)
281 +                return(NULL);
282 +        hvres[0] = odev.hres; hvres[1] = odev.vres;
283 +        return(&odev.v);
284 + }
285 +
286 +
287   int
288   dev_input()                     /* get X11 input */
289   {
# Line 262 | Line 303 | dev_flush()                    /* flush output */
303   {
304          qtUpdate();
305          glFlush();
306 +        rayqleft = RAYQLEN;
307          return(XPending(ourdisplay));
308   }
309  
# Line 273 | Line 315 | double rad;
315   {
316          register int    ci, j;
317          double  apexh, basez;
318 +                                        /* is window mapped? */
319 +        if (!mapped)
320 +                return;
321                                          /* compute apex height (0. to 1.) */
322          if (ip[2] > 1e6)
323                  apexh = 1. - 1./DEPTHFACT;
# Line 314 | Line 359 | mytmflags()                    /* figure out tone mapping flags */
359          for (cp = tail; *cp && *cp != '.'; cp++)
360                  ;
361          if (cp-tail == 3 && !strncmp(tail, "glx", 3))
362 <                return(TM_F_CAMERA);
362 >                return(TM_F_CAMERA|TM_F_NOSTDERR);
363          if (cp-tail == 4 && !strncmp(tail, "glxh", 4))
364 <                return(TM_F_HUMAN);
364 >                return(TM_F_HUMAN|TM_F_NOSTDERR);
365          error(USER, "illegal driver name");
366   }
367  
# Line 334 | Line 379 | initcones()                    /* initialize cone vertices */
379          for (i = 0; i < MAXCONE; i++) {
380                  d = (double)i/(MAXCONE-1); d *= d;      /* x^2 distribution */
381                  cone[i].rad = minrad + (1.-minrad)*d;
382 <                cone[i].nverts = MINVERT + (MAXVERT-MINVERT)*d;
382 >                cone[i].nverts = MINVERT + 0.5 + (MAXVERT-MINVERT)*d;
383                  cone[i].va = (FVECT *)malloc(cone[i].nverts*sizeof(FVECT));
384                  if (cone[i].va == NULL)
385                          error(SYSTEM, "out of memory in initcones");
# Line 567 | Line 612 | register XKeyPressedEvent  *ekey;
612                  inpresflags |= DFL(DC_RESUME);
613                  return;
614          case CTRL('R'):                 /* redraw screen */
615 +                if (nxtzmax > FTINY) {
616 +                        curzmax = nxtzmax;
617 +                        nxtzmax = 0.;
618 +                }
619                  glClear(GL_DEPTH_BUFFER_BIT);
620                  qtRedraw(0, 0, odev.hres, odev.vres);
621                  return;
622          case CTRL('L'):                 /* refresh from server */
623                  if (inpresflags & DFL(DC_REDRAW))
624                          return;
625 +                if (nxtzmax > FTINY) {
626 +                        curzmax = nxtzmax;
627 +                        nxtzmax = 0.;
628 +                }
629                  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
630                  draw_grids();
631                  glFlush();
632                  qtCompost(100);                 /* get rid of old values */
633                  inpresflags |= DFL(DC_REDRAW);  /* resend values from server */
634 +                rayqleft = 0;                   /* hold off update */
635                  return;
636          case 'K':                       /* kill rtrace process(es) */
637                  inpresflags |= DFL(DC_KILL);
# Line 627 | Line 681 | static
681   resizewindow(ersz)                      /* resize window */
682   register XConfigureEvent  *ersz;
683   {
684 +        glViewport(0, 0, ersz->width, ersz->height);
685 +
686          if (ersz->width == odev.hres && ersz->height == odev.vres)
687                  return;
688  
# Line 635 | Line 691 | register XConfigureEvent  *ersz;
691  
692          odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres);
693          odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres);
638
639        glViewport(0, 0, odev.hres, odev.vres);
694  
695          inpresflags |= DFL(DC_SETVIEW);
696   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines