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.5 by greg, Sat Feb 22 02:07:22 2003 UTC vs.
Revision 3.15 by greg, Tue May 25 22:04:13 2004 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Routines for reading instances and converting to OpenGL.
6   */
7  
8 < /* ====================================================================
9 < * The Radiance Software License, Version 1.0
10 < *
11 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 < *
14 < * Redistribution and use in source and binary forms, with or without
15 < * modification, are permitted provided that the following conditions
16 < * are met:
17 < *
18 < * 1. Redistributions of source code must retain the above copyright
19 < *         notice, this list of conditions and the following disclaimer.
20 < *
21 < * 2. Redistributions in binary form must reproduce the above copyright
22 < *       notice, this list of conditions and the following disclaimer in
23 < *       the documentation and/or other materials provided with the
24 < *       distribution.
25 < *
26 < * 3. The end-user documentation included with the redistribution,
27 < *           if any, must include the following acknowledgment:
28 < *             "This product includes Radiance software
29 < *                 (http://radsite.lbl.gov/)
30 < *                 developed by the Lawrence Berkeley National Laboratory
31 < *               (http://www.lbl.gov/)."
32 < *       Alternately, this acknowledgment may appear in the software itself,
33 < *       if and wherever such third-party acknowledgments normally appear.
34 < *
35 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
36 < *       and "The Regents of the University of California" must
37 < *       not be used to endorse or promote products derived from this
38 < *       software without prior written permission. For written
39 < *       permission, please contact [email protected].
40 < *
41 < * 5. Products derived from this software may not be called "Radiance",
42 < *       nor may "Radiance" appear in their name, without prior written
43 < *       permission of Lawrence Berkeley National Laboratory.
44 < *
45 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
49 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 < * SUCH DAMAGE.
57 < * ====================================================================
58 < *
59 < * This software consists of voluntary contributions made by many
60 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
61 < * information on Lawrence Berkeley National Laboratory, please see
62 < * <http://www.lbl.gov/>.
63 < */
8 > #include "copyright.h"
9  
10 + #include <stdio.h>
11 + #include <string.h>
12 + #include <time.h>
13 +
14 + #include "platform.h"
15 + #include "paths.h"
16 + #include "resolu.h"
17   #include "radogl.h"
18   #include "octree.h"
19  
# Line 74 | Line 26 | typedef struct {
26          char    octfile[256];                   /* octree file path */
27   } OCTINST;                              /* octree to instantiate */
28  
29 < static double  ogetflt();
30 < static long  ogetint();
31 < static char  *ogetstr();
32 < static int  loadobj();
33 < static void  skiptree();
34 < static void  octerror();
35 < static OCTINST  *getoct();
29 > static double  ogetflt(void);
30 > static long  ogetint(int);
31 > static char  *ogetstr(char *);
32 > static int  loadobj(void);
33 > static void  skiptree(void);
34 > static void  octerror(int etyp, char *msg);
35 > static OCTINST  *getoct(char *);
36  
37   static char  *infn;                     /* input file name */
38   static FILE  *infp;                     /* input file stream */
# Line 109 | Line 61 | register OBJREC        *o;
61                                  o->oargs.nsargs-1)
62                          objerror(o, USER, "bad transform");
63                  glPushAttrib(GL_TRANSFORM_BIT);
64 <                if (xfs.sca < 1.-FTINY | xfs.sca > 1.+FTINY)
64 >                if ((xfs.sca < 1.-FTINY) | (xfs.sca > 1.+FTINY))
65                          glEnable(GL_NORMALIZE);
66                  glMatrixMode(GL_MODELVIEW);
67                  glPushMatrix();
# Line 132 | Line 84 | register OBJREC        *o;
84                  glPopAttrib();
85          }
86          rgl_checkerr("creating instance");
87 +        return(0);
88   }
89  
90  
91   static int
92 < buildoctlist(lp)                        /* build octree list */
93 < LUENT   *lp;
92 > buildoctlist(lp, p)                     /* build octree list */
93 > const LUENT     *lp;
94 > void    *p;
95   {
96          int     old_dolights = dolights, old_domats = domats;
97          register OCTINST        *op = (OCTINST *)lp->data;
# Line 164 | Line 118 | loadoctrees()                          /* load octrees we've saved up */
118          while (ottab.tsiz) {
119                  if (!levelsleft--)
120                          error(USER, "too many octree levels -- instance loop?");
121 <                copystruct(&looptab, &ottab);
121 >                looptab = ottab;
122                  ottab.tsiz = 0;
123 <                nocts += lu_doall(&looptab, buildoctlist);
123 >                nocts += lu_doall(&looptab, buildoctlist, NULL);
124                  lu_done(&looptab);
125          }
126          return(nocts);
# Line 177 | Line 131 | static OCTINST *
131   getoct(name)                            /* get/assign octree list id */
132   char    *name;
133   {
180        extern char     *getpath(), *getlibpath();
134          char    *path;
135          register LUENT  *lp;
136          register OCTINST        *op;
# Line 191 | Line 144 | char   *name;
144                  strcpy(lp->key, name);
145          }
146          if ((op = (OCTINST *)lp->data) == NULL) {
147 <                path = getpath(name, getlibpath(), R_OK);
147 >                path = getpath(name, getrlibpath(), R_OK);
148                  if (path == NULL) {
149                          sprintf(errmsg, "cannot find octree \"%s\"", name);
150                          error(USER, errmsg);
# Line 205 | Line 158 | char   *name;
158          return(op);
159   memerr:
160          error(SYSTEM, "out of memory in getoct");
161 +        return NULL; /* pro forma return */
162   }
163  
164  
# Line 223 | Line 177 | FVECT  cent;
177                  sprintf(errmsg, "cannot open octree file \"%s\"", fname);
178                  error(SYSTEM, errmsg);
179          }
180 < #ifdef MSDOS
227 <        setmode(fileno(infp), O_BINARY);
228 < #endif
180 >        SET_FILE_BINARY(infp);
181                                          /* get header */
182          if (checkheader(infp, OCTFMT, NULL) < 0)
183                  octerror(USER, "not an octree");
184                                          /* check format */
185          if ((objsize = ogetint(2)-OCTMAGIC) <= 0 ||
186                          objsize > MAXOBJSIZ || objsize > sizeof(long))
187 <                octerror("incompatible octree format");
187 >                octerror(USER, "incompatible octree format");
188          if (cent != NULL) {             /* get boundaries (compute center) */
189                  for (i = 0; i < 3; i++)
190                          cent[i] = atof(ogetstr(sbuf));
# Line 262 | Line 214 | char  *fname;
214          
215          infn = fname;
216          infp = fopen(fname, "r");       /* assume already checked */
217 < #ifdef MSDOS
266 <        setmode(fileno(infp), O_BINARY);
267 < #endif
217 >        SET_FILE_BINARY(infp);
218                                          /* skip header */
219          getheader(infp, NULL, NULL);
220                                          /* get format */
# Line 391 | Line 341 | loadobj()                              /* get next object */
341                                          /* get name id */
342          ob.oname = ogetstr(idbuf);
343                                          /* get string arguments */
344 <        if (ob.oargs.nsargs = ogetint(2)) {
344 >        if ((ob.oargs.nsargs = ogetint(2))) {
345                  ob.oargs.sarg = (char **)malloc
346                                  (ob.oargs.nsargs*sizeof(char *));
347                  if (ob.oargs.sarg == NULL)
# Line 413 | Line 363 | loadobj()                              /* get next object */
363                  ob.oargs.iarg = NULL;
364   #endif
365                                          /* get real arguments */
366 <        if (ob.oargs.nfargs = ogetint(2)) {
367 <                ob.oargs.farg = (FLOAT *)malloc
368 <                                (ob.oargs.nfargs*sizeof(FLOAT));
366 >        if ((ob.oargs.nfargs = ogetint(2))) {
367 >                ob.oargs.farg = (RREAL *)malloc
368 >                                (ob.oargs.nfargs*sizeof(RREAL));
369                  if (ob.oargs.farg == NULL)
370                          goto memerr;
371                  for (i = 0; i < ob.oargs.nfargs; i++)
# Line 435 | Line 385 | loadobj()                              /* get next object */
385          return(nobjects++);             /* return object id */
386   memerr:
387          error(SYSTEM, "out of memory in loadobj");
388 +        return OVOID; /* pro forma return */
389   }
390  
391  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines