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.11 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Geometry drawing operations for OpenGL driver.
6   */
# Line 19 | Line 16 | static char SCCSid[] = "$SunId$ SGI";
16   #endif
17  
18   int     gmPortals = 0;                  /* current portal GL list id */
19 + static int      Nlists = 0;             /* number of lists allocated */
20   static char     *curportlist[MAXPORT];  /* current portal list */
21   static char     *newportlist[MAXPORT];  /* new portal file list */
22  
23   static struct gmEntry {
24          char    *gfile;                 /* geometry file name */
25          FVECT   cent;                   /* centroid */
26 <        FLOAT   rad;                    /* radius */
26 >        RREAL   rad;                    /* radius */
27          int     listid;                 /* display list identifier */
28 +        int     nlists;                 /* number of lists allocated */
29   } gmCurrent[MAXGEO], gmNext[MAXGEO];    /* current and next list */
30  
31   #define FORALLGEOM(ot,i)        for (i=0;i<MAXGEO&&ot[i].gfile!=NULL;i++)
32  
33   #define FORALLPORT(pl,i)                for (i=0;i<MAXPORT&&pl[i]!=NULL;i++)
34  
35 < extern char     *atos(), *sskip(), *sskip2();
35 > extern char     *nextword();
36  
37  
38   gmNewGeom(file)                 /* add new geometry to next list */
# Line 55 | Line 54 | char   *file;
54                          return;
55                  }
56                                          /* else load new octree */
57 <        gmNext[i].gfile = file;
57 >        gmNext[i].gfile = savestr(file);
58          dolights = 0;
59          domats = 1;
60 <        gmNext[i].listid = rgl_octlist(file, gmNext[i].cent, &gmNext[i].rad);
60 >        gmNext[i].listid = rgl_octlist(file, gmNext[i].cent, &gmNext[i].rad,
61 >                                        &gmNext[i].nlists);
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)
79 <                        glDeleteLists(gmCurrent[i].listid, 1);  /* not found */
78 >                if (j >= MAXGEO || gmNext[j].gfile == NULL) {
79 >                        glDeleteLists(gmCurrent[i].listid,      /* not found */
80 >                                        gmCurrent[i].nlists);
81 >                        freestr(gmCurrent[i].gfile);
82 >                }
83          }
84 <        bcopy((char *)gmNext, (char *)gmCurrent, sizeof(gmNext));
85 <        bzero((char *)gmNext, sizeof(gmNext));
84 >        bcopy((void *)gmNext, (void *)gmCurrent, sizeof(gmNext));
85 >        bzero((void *)gmNext, sizeof(gmNext));
86   }
87  
88  
89   int
90 < gmDrawGeom(clearports)          /* draw current list of octrees (and ports) */
87 < int     clearports;
90 > gmDrawGeom()                    /* draw current list of octrees */
91   {
92          register int    n;
93  
94          FORALLGEOM(gmCurrent, n)
95                  glCallList(gmCurrent[n].listid);
96 <        if (!n | !clearports | !gmPortals)
97 <                return(n);
98 <                                /* mark alpha channel over the portals */
99 <        glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
96 >        return(n);
97 > }
98 >
99 >
100 > gmDrawPortals(r, g, b, a)       /* draw portals with specific RGBA value */
101 > int     r, g, b, a;
102 > {
103 >        if (!gmPortals || r<0 & g<0 & b<0 & a<0)
104 >                return;
105 >        glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT|
106 >                        GL_POLYGON_BIT|GL_LIGHTING_BIT);
107 >        glDisable(GL_LIGHTING);
108 >        glDisable(GL_DITHER);
109 >        glShadeModel(GL_FLAT);
110 >        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
111 >                                        /* don't actually write depth */
112          glDepthMask(GL_FALSE);
113 <        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
114 <        glClear(GL_COLOR_BUFFER_BIT);
115 <        glColor4ub(0, 0, 0, 0xff);      /* write alpha buffer as mask */
113 >                                        /* draw only selected channels */
114 >        glColorMask(r>=0, g>=0, b>=0, a>=0);
115 >        glColor4ub(r&0xff, g&0xff, b&0xff, a&0xff);
116          glCallList(gmPortals);          /* draw them portals */
117          glPopAttrib();
103        return(n);
118   }
119  
120  
# Line 134 | Line 148 | char   *pflist;
148  
149          if (pflist == NULL)
150                  return;
151 <        while (*pflist) {
138 <                atos(newfile, sizeof(newfile), pflist);
139 <                if (!*newfile)
140 <                        break;
141 <                pflist = sskip(pflist);
151 >        while ((pflist = nextword(newfile, sizeof(newfile), pflist)) != NULL) {
152                  FORALLPORT(newportlist,i)
153                          if (!strcmp(newportlist[i], newfile))
154                                  goto endloop;   /* in list already */
# Line 168 | Line 178 | gmEndPortal()                  /* close portal list and return GL lis
178          FORALLPORT(newportlist, n);
179          if (!n) {                       /* free old GL list */
180                  if (gmPortals)
181 <                        glDeleteLists(gmPortals, 1);
181 >                        glDeleteLists(gmPortals, Nlists);
182                  gmPortals = 0;
183          } else
184                  qsort(newportlist, n, sizeof(char *), sstrcmp);
# Line 181 | Line 191 | gmEndPortal()                  /* close portal list and return GL lis
191                          FORALLPORT(newportlist, n);
192                          dolights = 0;
193                          domats = 0;
194 <                        gmPortals = rgl_filelist(n, newportlist);
194 >                        gmPortals = rgl_filelist(n, newportlist, &Nlists);
195                          break;
196                  }
197          FORALLPORT(curportlist, n)              /* free old file list */
198                  freestr(curportlist[n]);
199 <        bcopy((char *)newportlist, (char *)curportlist, sizeof(newportlist));
200 <        bzero((char *)newportlist, sizeof(newportlist));
199 >        bcopy((void *)newportlist, (void *)curportlist, sizeof(newportlist));
200 >        bzero((void *)newportlist, sizeof(newportlist));
201          return(gmPortals);                      /* return GL list id */
202   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines