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

Comparing ray/src/common/rglinst.c (file contents):
Revision 3.1 by gwlarson, Tue Jun 9 11:18:35 1998 UTC vs.
Revision 3.10 by schorsch, Thu Jun 26 00:58:09 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   * Routines for reading instances and converting to OpenGL.
6   */
7  
8 + #include "copyright.h"
9 +
10   #include "radogl.h"
11   #include "octree.h"
12 + #include "platform.h"
13  
14 + #define MAXLEVEL        16              /* maximum instance hierarchy level */
15 +
16   typedef struct {
17          int     listid;                         /* our list id */
18          short   localmatl;                      /* uses local material only */
# Line 18 | Line 20 | typedef struct {
20          char    octfile[256];                   /* octree file path */
21   } OCTINST;                              /* octree to instantiate */
22  
21 OBJECT  nobjects;                       /* number of objects loaded so far */
22
23 extern int      free();
24
23   static double  ogetflt();
24   static long  ogetint();
25   static char  *ogetstr();
26 < static int  loadobj(), octerror(), skiptree();
26 > static int  loadobj();
27 > static void  skiptree();
28 > static void  octerror();
29   static OCTINST  *getoct();
30  
31   static char  *infn;                     /* input file name */
# Line 33 | Line 33 | static FILE  *infp;                    /* input file stream */
33   static int  objsize;                    /* size of stored OBJECT's */
34   static short  otypmap[NUMOTYPE+8];      /* object type map */
35  
36 < static long     imhash(mod) char *mod; {return((long)mod);}
36 > static unsigned long    imhash(mod) char *mod; {return((unsigned long)mod);}
37   static LUTAB    imtab = {imhash,NULL,NULL,NULL,0,NULL,0};
38  
39   static LUTAB    ottab = LU_SINIT(free,free);
40  
41  
42 + int
43   o_instance(o)                           /* convert instance to list call */
44   register OBJREC *o;
45   {
# Line 67 | Line 68 | register OBJREC        *o;
68          }
69          ot = getoct(o->oargs.sarg[0]);  /* get octree reference */
70          if (ot->localmatl &= o->os != NULL)     /* set material */
71 <                setmaterial(o->os, ot->cent, 0);
71 >                setmaterial((MATREC *)o->os, ot->cent, 0);
72                                          /* call the assigned list */
73          glCallList(ot->listid);
74  
75          if (o->oargs.nsargs > 1) {      /* end transform */
76 +                glMatrixMode(GL_MODELVIEW);
77                  glPopMatrix();
78                  glPopAttrib();
79          }
80          rgl_checkerr("creating instance");
81 +        return(0);
82   }
83  
84  
# Line 101 | Line 104 | LUENT  *lp;
104   int
105   loadoctrees()                           /* load octrees we've saved up */
106   {
107 +        int     levelsleft = MAXLEVEL;
108          int     nocts = 0;
109          LUTAB   looptab;
110                                  /* loop through new octree references */
111          while (ottab.tsiz) {
112 +                if (!levelsleft--)
113 +                        error(USER, "too many octree levels -- instance loop?");
114                  copystruct(&looptab, &ottab);
115                  ottab.tsiz = 0;
116                  nocts += lu_doall(&looptab, buildoctlist);
# Line 118 | Line 124 | static OCTINST *
124   getoct(name)                            /* get/assign octree list id */
125   char    *name;
126   {
121        extern char     *getpath(), *getlibpath();
127          char    *path;
128          register LUENT  *lp;
129          register OCTINST        *op;
# Line 132 | Line 137 | char   *name;
137                  strcpy(lp->key, name);
138          }
139          if ((op = (OCTINST *)lp->data) == NULL) {
140 <                path = getpath(name, getlibpath(), R_OK);
140 >                path = getpath(name, getrlibpath(), R_OK);
141                  if (path == NULL) {
142                          sprintf(errmsg, "cannot find octree \"%s\"", name);
143                          error(USER, errmsg);
# Line 164 | Line 169 | FVECT  cent;
169                  sprintf(errmsg, "cannot open octree file \"%s\"", fname);
170                  error(SYSTEM, errmsg);
171          }
172 < #ifdef MSDOS
168 <        setmode(fileno(infp), O_BINARY);
169 < #endif
172 >        SET_FILE_BINARY(infp);
173                                          /* get header */
174          if (checkheader(infp, OCTFMT, NULL) < 0)
175                  octerror(USER, "not an octree");
# Line 191 | Line 194 | FVECT  cent;
194   }
195  
196  
197 + int
198   loadoct(fname)                          /* read in objects from octree */
199   char  *fname;
200   {
# Line 202 | Line 206 | char  *fname;
206          
207          infn = fname;
208          infp = fopen(fname, "r");       /* assume already checked */
209 < #ifdef MSDOS
206 <        setmode(fileno(infp), O_BINARY);
207 < #endif
209 >        SET_FILE_BINARY(infp);
210                                          /* skip header */
211          getheader(infp, NULL, NULL);
212                                          /* get format */
# Line 280 | Line 282 | ogetflt()                      /* get a floating point number */
282   }
283          
284  
285 < static
285 > static void
286   skiptree()                              /* skip octree on input */
287   {
288          register int  i;
# Line 305 | Line 307 | skiptree()                             /* skip octree on input */
307   }
308  
309  
310 < static
310 > static int
311   loadobj()                               /* get next object */
312   {
313          static OBJREC    ob;
# Line 354 | Line 356 | loadobj()                              /* get next object */
356   #endif
357                                          /* get real arguments */
358          if (ob.oargs.nfargs = ogetint(2)) {
359 <                ob.oargs.farg = (FLOAT *)malloc
360 <                                (ob.oargs.nfargs*sizeof(FLOAT));
359 >                ob.oargs.farg = (RREAL *)malloc
360 >                                (ob.oargs.nfargs*sizeof(RREAL));
361                  if (ob.oargs.farg == NULL)
362                          goto memerr;
363                  for (i = 0; i < ob.oargs.nfargs; i++)
# Line 378 | Line 380 | memerr:
380   }
381  
382  
383 < static
383 > static void
384   octerror(etyp, msg)                     /* octree error */
385   int  etyp;
386   char  *msg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines