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

Comparing ray/src/hd/rhd_geom.c (file contents):
Revision 3.2 by gwlarson, Sun Dec 20 20:35:43 1998 UTC vs.
Revision 3.7 by gwlarson, Fri Jan 29 15:04:03 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1999 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 33 | Line 33 | static struct gmEntry {
33  
34   #define FORALLPORT(pl,i)                for (i=0;i<MAXPORT&&pl[i]!=NULL;i++)
35  
36 < extern char     *atos(), *sskip(), *sskip2();
36 > extern char     *nextword();
37  
38  
39   gmNewGeom(file)                 /* add new geometry to next list */
# Line 55 | Line 55 | char   *file;
55                          return;
56                  }
57                                          /* else load new octree */
58 <        gmNext[i].gfile = file;
58 >        gmNext[i].gfile = savestr(file);
59          dolights = 0;
60          domats = 1;
61          gmNext[i].listid = rgl_octlist(file, gmNext[i].cent, &gmNext[i].rad);
62 +        gmNext[i].rad *= 1.732;         /* go to corners */
63   #ifdef DEBUG
64          fprintf(stderr, "Loaded octree \"%s\" into listID %d with radius %f\n",
65                          file, gmNext[i].listid, gmNext[i].rad);
# Line 74 | Line 75 | gmEndGeom()                    /* make next list current */
75                  FORALLGEOM(gmNext, j)
76                          if (gmNext[j].listid == gmCurrent[i].listid)
77                                  break;
78 <                if (j >= MAXGEO || gmNext[j].gfile == NULL)
78 >                if (j >= MAXGEO || gmNext[j].gfile == NULL) {
79                          glDeleteLists(gmCurrent[i].listid, 1);  /* not found */
80 +                        freestr(gmCurrent[i].gfile);
81 +                }
82          }
83          bcopy((char *)gmNext, (char *)gmCurrent, sizeof(gmNext));
84          bzero((char *)gmNext, sizeof(gmNext));
# Line 83 | Line 86 | gmEndGeom()                    /* make next list current */
86  
87  
88   int
89 < gmDrawGeom(clearports)          /* draw current list of octrees (and ports) */
87 < int     clearports;
89 > gmDrawGeom()                    /* draw current list of octrees */
90   {
91          register int    n;
92  
93          FORALLGEOM(gmCurrent, n)
94                  glCallList(gmCurrent[n].listid);
95 <        if (!n | !clearports | !gmPortals)
96 <                return(n);
97 <                                /* mark alpha channel over the portals */
98 <        glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
95 >        return(n);
96 > }
97 >
98 >
99 > gmDrawPortals(r, g, b, a)       /* draw portals with specific RGBA value */
100 > int     r, g, b, a;
101 > {
102 >        if (!gmPortals || r<0 & g<0 & b<0 & a<0)
103 >                return;
104 >        glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT|
105 >                        GL_POLYGON_BIT|GL_LIGHTING_BIT);
106 >        glDisable(GL_LIGHTING);
107 >        glDisable(GL_DITHER);
108 >        glShadeModel(GL_FLAT);
109 >        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
110 >                                        /* don't actually write depth */
111          glDepthMask(GL_FALSE);
112 <        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
113 <        glClear(GL_COLOR_BUFFER_BIT);
114 <        glColor4ub(0, 0, 0, 0xff);      /* write alpha buffer as mask */
112 >                                        /* draw only selected channels */
113 >        glColorMask(r>=0, g>=0, b>=0, a>=0);
114 >        glColor4ub(r&0xff, g&0xff, b&0xff, a&0xff);
115          glCallList(gmPortals);          /* draw them portals */
116          glPopAttrib();
103        return(n);
117   }
118  
119  
# Line 134 | Line 147 | char   *pflist;
147  
148          if (pflist == NULL)
149                  return;
150 <        while (*pflist) {
138 <                atos(newfile, sizeof(newfile), pflist);
139 <                if (!*newfile)
140 <                        break;
141 <                pflist = sskip(pflist);
150 >        while ((pflist = nextword(newfile, sizeof(newfile), pflist)) != NULL) {
151                  FORALLPORT(newportlist,i)
152                          if (!strcmp(newportlist[i], newfile))
153                                  goto endloop;   /* in list already */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines