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

Comparing ray/src/hd/rhd_glx1.c (file contents):
Revision 3.2 by schorsch, Mon Jul 21 22:30:18 2003 UTC vs.
Revision 3.10 by greg, Fri Oct 5 19:19:16 2018 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9   #include "standard.h"
10  
11   #include  <GL/glx.h>
12 + #include  <GL/glu.h>
13  
14 + #include "platform.h"
15   #include "rhd_qtree.h"
16 <
16 > #include "rhdriver.h"
17 > #include "rhdisp.h"
18   #include  "x11icon.h"
19  
20   #ifndef RAYQLEN
# Line 58 | Line 61 | static const char      RCSid[] = "$Id$";
61  
62   struct driver   odev;                   /* global device driver structure */
63  
64 + TMstruct        *tmGlobal;              /* global tone-mapping structure */
65 +
66   char odev_args[64];                     /* command arguments */
67  
68   static XEvent  currentevent;            /* current event */
# Line 85 | Line 90 | static int     inpresflags;            /* input result flags */
90  
91   static int      headlocked = 0;         /* lock vertical motion */
92  
88 static int  resizewindow(), getevent(), getkey(), moveview(),
89                initcones(), freecones(),
90                getmove(), fixwindow(), mytmflags();
93  
94 + static int mytmflags(void);
95 + static void initcones(void);
96 + static void freecones(void);
97 + static void getevent(void);
98 + static void draw3dline(FVECT    wp[2]);
99 + static void draw_grids(void);
100 + static int moveview(int dx, int dy, int mov, int        orb);
101 + static void getmove(XButtonPressedEvent *ebut);
102 + static void getkey(XKeyPressedEvent  *ekey);
103 + static void fixwindow(XExposeEvent  *eexp);
104 + static void resizewindow(XConfigureEvent  *ersz);
105  
106 < dev_open(id)                    /* initialize X11 driver */
107 < char  *id;
106 >
107 > void
108 > dev_open(
109 >        char  *id
110 > )
111   {
112          extern char     *getenv();
113          static RGBPRIMS myprims = STDPRIMS;
# Line 128 | Line 144 | char  *id;
144                                  &myprims[BLU][CIEX],&myprims[BLU][CIEY],
145                                  &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6)
146                  dpri = myprims;
147 <        if (tmInit(mytmflags(), dpri, gamval) == NULL)
147 >        tmGlobal = tmInit(mytmflags(), dpri, gamval);
148 >        if (tmGlobal == NULL)
149                  error(SYSTEM, "not enough memory in dev_open");
150                                          /* open window */
151          ourwinattr.background_pixel = ourblack;
# Line 187 | Line 204 | char  *id;
204   }
205  
206  
207 < dev_close()                     /* close our display and free resources */
207 > void
208 > dev_close(void)                 /* close our display and free resources */
209   {
210          glXMakeCurrent(ourdisplay, None, NULL);
211          glXDestroyContext(ourdisplay, gctx);
# Line 196 | Line 214 | dev_close()                    /* close our display and free resources
214          XCloseDisplay(ourdisplay);
215          ourdisplay = NULL;
216          qtFreeLeaves();
217 <        tmDone(NULL);
217 >        tmDone(tmGlobal);
218          freecones();
219          odev.v.type = 0;
220          odev.hres = odev.vres = 0;
# Line 204 | Line 222 | dev_close()                    /* close our display and free resources
222   }
223  
224  
225 < dev_clear()                     /* clear our quadtree */
225 > void
226 > dev_clear(void)                 /* clear our quadtree */
227   {
228          qtCompost(100);
229          glClear(GL_DEPTH_BUFFER_BIT);
# Line 213 | Line 232 | dev_clear()                    /* clear our quadtree */
232  
233  
234   int
235 < dev_view(nv)                    /* assign new driver view */
236 < register VIEW   *nv;
235 > dev_view(                       /* assign new driver view */
236 >        VIEW    *nv
237 > )
238   {
239          if (nv->type == VT_PAR ||               /* check view legality */
240                          nv->horiz > 160. || nv->vert > 160.) {
# Line 264 | Line 284 | register VIEW  *nv;
284   }
285  
286  
287 < dev_section(ofn)                /* add octree for geometry rendering */
288 < char    *ofn;
287 > void
288 > dev_section(            /* add octree for geometry rendering */
289 >        char    *gfn,
290 >        char    *pfn
291 > )
292   {
293          /* unimplemented */
294   }
295  
296  
297 < dev_auxcom(cmd, args)           /* process an auxiliary command */
298 < char    *cmd, *args;
297 > void
298 > dev_auxcom(             /* process an auxiliary command */
299 >        char    *cmd,
300 >        char    *args
301 > )
302   {
303          sprintf(errmsg, "%s: unknown command", cmd);
304          error(COMMAND, errmsg);
# Line 280 | Line 306 | char   *cmd, *args;
306  
307  
308   VIEW *
309 < dev_auxview(n, hvres)           /* return nth auxiliary view */
310 < int     n;
311 < int     hvres[2];
309 > dev_auxview(            /* return nth auxiliary view */
310 >        int     n,
311 >        int     hvres[2]
312 > )
313   {
314          if (n)
315                  return(NULL);
# Line 292 | Line 319 | int    hvres[2];
319  
320  
321   int
322 < dev_input()                     /* get X11 input */
322 > dev_input(void)                 /* get X11 input */
323   {
324          inpresflags = 0;
325  
# Line 306 | Line 333 | dev_input()                    /* get X11 input */
333  
334  
335   int
336 < dev_flush()                     /* flush output */
336 > dev_flush(void)                 /* flush output */
337   {
338          qtUpdate();
339          glFlush();
# Line 315 | Line 342 | dev_flush()                    /* flush output */
342   }
343  
344  
345 < dev_cone(rgb, ip, rad)          /* render a cone in view coordinates */
346 < BYTE    rgb[3];
347 < FVECT   ip;
348 < double  rad;
345 > void
346 > dev_cone(               /* render a cone in view coordinates */
347 >        uby8    rgb[3],
348 >        FVECT   ip,
349 >        double  rad
350 > )
351   {
352 <        register int    ci, j;
352 >        int     ci, j;
353          double  apexh, basez;
354                                          /* is window mapped? */
355          if (!mapped)
# Line 355 | Line 384 | double rad;
384  
385  
386   static int
387 < mytmflags()                     /* figure out tone mapping flags */
387 > mytmflags(void)                 /* figure out tone mapping flags */
388   {
389          extern char     *progname;
390 <        register char   *cp, *tail;
390 >        char    *cp, *tail;
391                                          /* find basic name */
392          for (cp = tail = progname; *cp; cp++)
393                  if (*cp == '/')
# Line 370 | Line 399 | mytmflags()                    /* figure out tone mapping flags */
399          if (cp-tail == 5 && !strncmp(tail, "glx1h", 5))
400                  return(TM_F_HUMAN|TM_F_NOSTDERR);
401          error(USER, "illegal driver name");
402 +        return -1; /* pro forma return */
403   }
404  
405  
406 < static
407 < initcones()                     /* initialize cone vertices */
406 > static void
407 > initcones(void)                 /* initialize cone vertices */
408   {
409 <        register int    i, j;
409 >        int     i, j;
410          double  minrad, d;
411  
412          if (cone[0].nverts)
# Line 400 | Line 430 | initcones()                    /* initialize cone vertices */
430   }
431  
432  
433 < static
434 < freecones()                     /* free cone vertices */
433 > static void
434 > freecones(void)                 /* free cone vertices */
435   {
436 <        register int    i;
436 >        int     i;
437  
438          for (i = MAXCONE; i--; )
439                  if (cone[i].nverts) {
# Line 414 | Line 444 | freecones()                    /* free cone vertices */
444   }
445  
446  
447 < static
448 < getevent()                      /* get next event */
447 > static void
448 > getevent(void)                  /* get next event */
449   {
450          XNextEvent(ourdisplay, levptr(XEvent));
451          switch (levptr(XEvent)->type) {
# Line 435 | Line 465 | getevent()                     /* get next event */
465                  getkey(levptr(XKeyPressedEvent));
466                  break;
467          case ButtonPress:
468 <                getmove(levptr(XButtonPressedEvent));
468 >                switch (levptr(XButtonPressedEvent)->button) {
469 >                case Button4:           /* wheel up */
470 >                case Button5:           /* wheel down */
471 >                        break;
472 >                default:
473 >                        getmove(levptr(XButtonPressedEvent));
474 >                        break;
475 >                }
476                  break;
477          }
478   }
479  
480  
481 < static
482 < draw3dline(wp)                  /* draw 3d line in world coordinates */
483 < register FVECT  wp[2];
481 > static void
482 > draw3dline(                     /* draw 3d line in world coordinates */
483 >        FVECT   wp[2]
484 > )
485   {
486          glVertex3d(wp[0][0], wp[0][1], wp[0][2]);
487          glVertex3d(wp[1][0], wp[1][1], wp[1][2]);
488   }
489  
490  
491 < static
492 < draw_grids()                    /* draw holodeck section grids */
491 > static void
492 > draw_grids(void)                        /* draw holodeck section grids */
493   {
494 <        static BYTE     gridrgba[4] = {0x0, 0xff, 0xff, 0x00};
494 >        static uby8     gridrgba[4] = {0x0, 0xff, 0xff, 0x00};
495          double  xmin, xmax, ymin, ymax, zmin, zmax;
496 <        double  d, cx, sx, crad;
459 <        FVECT   vx, vy;
460 <        register int    i, j;
496 >        double  d;
497                                          /* can we even do it? */
498          if (!mapped || odev.v.type != VT_PER)
499                  return;
# Line 498 | Line 534 | draw_grids()                   /* draw holodeck section grids */
534   }
535  
536  
537 < static
538 < moveview(dx, dy, mov, orb)      /* move our view */
539 < int     dx, dy, mov, orb;
537 > static int
538 > moveview(       /* move our view */
539 >        int     dx,
540 >        int     dy,
541 >        int     mov,
542 >        int     orb
543 > )
544   {
545          VIEW    nv;
546          FVECT   odir, v1;
547          double  d;
548 <        register int    li;
548 >        int     li;
549                                  /* start with old view */
550          nv = odev.v;
551                                  /* change view direction */
# Line 523 | Line 563 | int    dx, dy, mov, orb;
563                  VSUM(nv.vp, qtL.wp[li], odir, -1.);
564                  spinvector(nv.vdir, nv.vdir, nv.vup, d);
565          } else if (orb) {               /* orbit up/down */
566 <                fcross(v1, odir, nv.vup);
567 <                if (normalize(v1) == 0.)
566 >                if (geodesic(odir, odir, nv.vup,
567 >                                d=MOVDEG*PI/180.*orb, GEOD_RAD) == 0.0)
568                          return(0);
529                spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb);
569                  VSUM(nv.vp, qtL.wp[li], odir, -1.);
570 <                spinvector(nv.vdir, nv.vdir, v1, d);
570 >                geodesic(nv.vdir, nv.vdir, nv.vup, d, GEOD_RAD);
571          } else if (mov) {               /* move forward/backward */
572                  d = MOVPCT/100. * mov;
573                  VSUM(nv.vp, nv.vp, odir, d);
# Line 546 | Line 585 | int    dx, dy, mov, orb;
585   }
586  
587  
588 < static
589 < getmove(ebut)                           /* get view change */
590 < XButtonPressedEvent     *ebut;
588 > static void
589 > getmove(                                /* get view change */
590 >        XButtonPressedEvent     *ebut
591 > )
592   {
593          int     movdir = MOVDIR(ebut->button);
594          int     movorb = MOVORB(ebut->state);
# Line 588 | Line 628 | XButtonPressedEvent    *ebut;
628   }
629  
630  
631 < static
632 < getkey(ekey)                            /* get input key */
633 < register XKeyPressedEvent  *ekey;
631 > static void
632 > getkey(                         /* get input key */
633 >        XKeyPressedEvent  *ekey
634 > )
635   {
636          int  n;
637          char    buf[8];
# Line 659 | Line 700 | register XKeyPressedEvent  *ekey;
700   }
701  
702  
703 < static
704 < fixwindow(eexp)                         /* repair damage to window */
705 < register XExposeEvent  *eexp;
703 > static void
704 > fixwindow(                              /* repair damage to window */
705 >        XExposeEvent  *eexp
706 > )
707   {
708          int     xmin, xmax, ymin, ymax;
709  
# Line 684 | Line 726 | register XExposeEvent  *eexp;
726   }
727  
728  
729 < static
730 < resizewindow(ersz)                      /* resize window */
731 < register XConfigureEvent  *ersz;
729 > static void
730 > resizewindow(                   /* resize window */
731 >        XConfigureEvent  *ersz
732 > )
733   {
734          glViewport(0, 0, ersz->width, ersz->height);
735  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines