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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines