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

Comparing ray/src/common/rglfile.c (file contents):
Revision 3.2 by gwlarson, Mon Aug 17 17:57:59 1998 UTC vs.
Revision 3.10 by schorsch, Fri Nov 14 17:22:06 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   * Load Radiance object(s) and create OpenGL display lists
6   */
7  
8 + #include "copyright.h"
9 +
10 + #include <ctype.h>
11 +
12 + #include "rtprocess.h"
13   #include "radogl.h"
14  
15   #ifndef NLIST2ALLOC
16   #define NLIST2ALLOC     16              /* batch of display lists to get */
17   #endif
18  
17 extern int      o_sphere(), o_face(), o_cone(), o_ring(),
18                o_source(), o_instance();
19
20 extern int      m_normal(), m_glass(), m_aniso(), m_brdf(), m_brdf2(),
21                m_light(), m_prism(), m_mirror();
22
19   FUN  ofun[NUMOTYPE] = INIT_OTYPE;
20  
21 + static int      nextlist, nlistleft = 0;
22  
23 < static
23 >
24 > static void
25   initotypes()                    /* initialize ofun array */
26   {
27          if (ofun[OBJ_SPHERE].funp == o_sphere)
# Line 39 | Line 37 | initotypes()                   /* initialize ofun array */
37          ofun[OBJ_RING].funp = o_ring;
38          ofun[OBJ_SOURCE].funp = o_source;
39          ofun[OBJ_INSTANCE].funp = o_instance;
40 +        ofun[OBJ_MESH].funp = o_unsupported;
41                                                  /* assign material types */
42          ofun[MAT_TRANS].funp =
43          ofun[MAT_PLASTIC].funp =
# Line 69 | Line 68 | initotypes()                   /* initialize ofun array */
68   int
69   newglist()                      /* allocate an OGL list id */
70   {
71 <        static int      nextlist, nleft = 0;
73 <
74 <        if (!nleft--) {
71 >        if (!nlistleft--) {
72                  nextlist = glGenLists(NLIST2ALLOC);
73 <                nleft = NLIST2ALLOC-1;
73 >                if (!nextlist)
74 >                        error(SYSTEM, "no list space left in newglist");
75 >                nlistleft = NLIST2ALLOC-1;
76          }
77          return(nextlist++);
78   }
79  
80  
81 + void
82   rgl_checkerr(where)             /* check for GL or GLU error */
83   char    *where;
84   {
# Line 93 | Line 93 | char   *where;
93  
94  
95   int
96 < rgl_filelist(ic, inp)           /* load scene files into display list */
96 > rgl_filelist(ic, inp, nl)       /* load scene files into display list */
97   int     ic;
98   char    **inp;
99 + int     *nl;                    /* returned number of lists (optional) */
100   {
101          int     listid;
102  
# Line 110 | Line 111 | char   **inp;
111          glEndList();            /* end of top display list */
112          lightdefs();            /* define light sources */
113          loadoctrees();          /* load octrees (sublists) for instances */
114 +        if (nl != NULL)         /* return total number of lists allocated */
115 +                *nl = nextlist - listid;
116          return(listid);         /* all done -- return list id */
117   }
118  
119  
120   int
121 < rgl_octlist(fname, cent, radp)  /* load octree objects into display list */
121 > rgl_octlist(fname, cent, radp, nl)      /* load scen into display list */
122   char    *fname;
123   FVECT   cent;                   /* returned octree center (optional) */
124 < FLOAT   *radp;                  /* returned octree size (optional) */
124 > RREAL   *radp;                  /* returned octree size (optional) */
125 > int     *nl;                    /* returned number of lists (optional) */
126   {
127          double  r;
128          int     listid;
# Line 137 | Line 141 | FLOAT  *radp;                  /* returned octree size (optional) */
141          glEndList();            /* close top list */
142          lightdefs();            /* define light sources */
143          loadoctrees();          /* load referenced octrees into sublists */
144 +        if (nl != NULL)         /* return total number of lists allocated */
145 +                *nl = nextlist - listid;
146          return(listid);
147   }
148  
149  
150 + void
151   rgl_load(inpspec)               /* convert scene description into OGL calls */
152   char    *inpspec;
153   {
147        FILE    *popen();
154          char    *fgetline();
155          FILE    *infp;
156          char    buf[1024];
# Line 183 | Line 189 | char   *inpspec;
189   }
190  
191  
192 + void
193   rgl_object(name, fp)                    /* read the next object */
194   char  *name;
195   FILE  *fp;
# Line 194 | Line 201 | FILE  *fp;
201          strcpy(sbuf, "EOF");
202          fgetword(sbuf, MAXSTR, fp);
203          ob.omod = 0;                    /* use ob.os for pointer to material */
204 <        if (!strcmp(sbuf, VOIDID))
204 >        if (!strcmp(sbuf, VOIDID) || !strcmp(sbuf, ALIASMOD))
205                  ob.os = NULL;
206          else
207                  ob.os = (char *)getmatp(sbuf);
208                                          /* get type */
209          strcpy(sbuf, "EOF");
210          fgetword(sbuf, MAXSTR, fp);
211 <        if (!strcmp(sbuf, ALIASID))
205 <                ob.otype = -1;
206 <        else if ((ob.otype = otype(sbuf)) < 0) {
211 >        if ((ob.otype = otype(sbuf)) < 0) {
212                  sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf);
213                  error(USER, errmsg);
214          }
# Line 212 | Line 217 | FILE  *fp;
217          fgetword(sbuf, MAXSTR, fp);
218          ob.oname = sbuf;
219                                          /* get arguments */
220 <        if (ob.otype == -1) {
220 >        if (ob.otype == MOD_ALIAS) {
221                  char  sbuf2[MAXSTR];            /* get alias */
222                  strcpy(sbuf2, "EOF");
223                  fgetword(sbuf2, MAXSTR, fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines