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

Comparing ray/src/common/rglsurf.c (file contents):
Revision 3.1 by gwlarson, Tue Jun 9 11:18:36 1998 UTC vs.
Revision 3.7 by greg, Wed Apr 23 02:28: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   * Convert Radiance -> OpenGL surfaces.
6   */
7  
8 + #include "copyright.h"
9 +
10   #include "radogl.h"
11  
12   #ifndef NSLICES
# Line 29 | Line 28 | static char    *glu_rout = "unk";      /* active GLU routine *
28   #define NOPOLY()        if (curpolysize) {glEnd(); curpolysize = 0;} else
29  
30  
31 + void
32   setmaterial(mp, cent, ispoly)   /* prepare for new material */
33   register MATREC *mp;
34   FVECT   cent;
# Line 80 | Line 80 | register FVECT v[];    /* vertex list */
80   }
81  
82  
83 < static
84 < glu_error(en)                   /* report a tessellation error as a warning */
83 > static void
84 > glu_error(en)                   /* report an error as a warning */
85   GLenum  en;
86   {
87          sprintf(errmsg, "GLU error %s: %s", glu_rout, gluErrorString(en));
# Line 89 | Line 89 | GLenum en;
89   }
90  
91  
92 + static void
93 + myCombine(coords, vertex_data, weight, dataOut)
94 + register GLdouble       coords[3];
95 + GLdouble        *vertex_data[4];
96 + GLfloat weight[4];
97 + GLdouble        **dataOut;
98 + {
99 +        register GLdouble       *newvert;
100 +
101 +        newvert = (GLdouble *)malloc(3*sizeof(GLdouble));
102 +        if (newvert == NULL)
103 +                error(SYSTEM, "out of memory in myCombine");
104 +        VCOPY(newvert, coords);         /* no data, just coordinates */
105 +        *dataOut = newvert;
106 + }
107 +
108 +
109   static
110   newtess()                       /* allocate GLU tessellation object */
111   {
# Line 97 | Line 114 | newtess()                      /* allocate GLU tessellation object */
114          gluTessCallback(gluto, GLU_TESS_BEGIN, glBegin);
115          gluTessCallback(gluto, GLU_TESS_VERTEX, glVertex3dv);
116          gluTessCallback(gluto, GLU_TESS_END, glEnd);
117 +        gluTessCallback(gluto, GLU_TESS_COMBINE, myCombine);
118          gluTessCallback(gluto, GLU_TESS_ERROR, glu_error);
119          gluTessProperty(gluto, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
120   }
# Line 112 | Line 130 | newquadric()                   /* allocate GLU quadric structure */
130   }
131  
132  
133 + int
134   o_face(o)                       /* convert a face */
135   register OBJREC *o;
136   {
# Line 123 | Line 142 | register OBJREC        *o;
142                  objerror(o, USER, "bad # real arguments");
143          area = polyarea(cent, norm, o->oargs.nfargs/3, (FVECT *)o->oargs.farg);
144          if (area <= FTINY)
145 <                return;
145 >                return(0);
146          if (dolights)                                   /* check for source */
147 <                doflatsrc(o->os, cent, norm, area);
148 <        setmaterial(o->os, cent, 1);                    /* set material */
147 >                doflatsrc((MATREC *)o->os, cent, norm, area);
148 >        setmaterial((MATREC *)o->os, cent, 1);          /* set material */
149          if (o->oargs.nfargs/3 != curpolysize) {
150                  if (curpolysize) glEnd();
151                  curpolysize = o->oargs.nfargs/3;
# Line 158 | Line 177 | register OBJREC        *o;
177                                          (GLdouble)o->oargs.farg[3*i+1],
178                                          (GLdouble)o->oargs.farg[3*i+2]);
179          }
180 +        return(0);
181   }
182  
183  
184 + void
185   surfclean()                     /* clean up surface routines */
186   {
187          setmaterial(NULL, NULL, 0);
# Line 176 | Line 197 | surfclean()                    /* clean up surface routines */
197   }
198  
199  
200 + int
201   o_sphere(o)                     /* convert a sphere */
202   register OBJREC *o;
203   {
# Line 186 | Line 208 | register OBJREC        *o;
208                  o->otype = o->otype==OBJ_SPHERE ? OBJ_BUBBLE : OBJ_SPHERE;
209                  o->oargs.farg[3] = -o->oargs.farg[3];
210          } else if (o->oargs.farg[3] <= FTINY)
211 <                return;
211 >                return(0);
212          if (dolights)
213 <                dosphsrc(o->os, o->oargs.farg,
213 >                dosphsrc((MATREC *)o->os, o->oargs.farg,
214                                  PI*o->oargs.farg[3]*o->oargs.farg[3]);
215 <        setmaterial(o->os, o->oargs.farg, 0);
215 >        setmaterial((MATREC *)o->os, o->oargs.farg, 0);
216          if (gluqo == NULL) newquadric();
217          glu_rout = "making sphere";
218          gluQuadricOrientation(gluqo,
# Line 202 | Line 224 | register OBJREC        *o;
224                          (GLdouble)o->oargs.farg[2]);
225          gluSphere(gluqo, (GLdouble)o->oargs.farg[3], NSLICES, NSTACKS);
226          glPopMatrix();
227 <        rgl_checkerr("creating sphere");
227 >        return(0);
228   }
229  
230  
231 + int
232   o_cone(o)                       /* convert a cone or cylinder */
233   register OBJREC *o;
234   {
# Line 215 | Line 238 | register OBJREC *o;
238  
239          iscyl = o->otype==OBJ_CYLINDER | o->otype==OBJ_TUBE;
240          if (o->oargs.nfargs != (iscyl ? 7 : 8))
241 <                objerror(o, "bad # real arguments");
241 >                objerror(o, USER, "bad # real arguments");
242          if (o->oargs.farg[6] < -FTINY) {
243                  o->oargs.farg[6] = -o->oargs.farg[6];
244                  if (iscyl)
# Line 230 | Line 253 | register OBJREC *o;
253                  objerror(o, USER, "illegal radii");
254          if (o->oargs.farg[6] <= FTINY && (iscyl || o->oargs.farg[7] <= FTINY))
255                  return;
256 <        if (o->oargs.farg[6] < 0.)              /* complains for tiny neg's */
257 <                o->oargs.farg[6] = 0.;
258 <        if (!iscyl && o->oargs.farg[7] < 0.)
259 <                o->oargs.farg[7] = 0.;
256 >        if (!iscyl) {
257 >                if (o->oargs.farg[6] < 0.)      /* complains for tiny neg's */
258 >                        o->oargs.farg[6] = 0.;
259 >                if (o->oargs.farg[7] < 0.)
260 >                        o->oargs.farg[7] = 0.;
261 >        }
262          cent[0] = .5*(o->oargs.farg[0] + o->oargs.farg[3]);
263          cent[1] = .5*(o->oargs.farg[1] + o->oargs.farg[4]);
264          cent[2] = .5*(o->oargs.farg[2] + o->oargs.farg[5]);
265 <        setmaterial(o->os, cent, 0);
265 >        setmaterial((MATREC *)o->os, cent, 0);
266          if (gluqo == NULL) newquadric();
267          glu_rout = "making cylinder";
268          gluQuadricOrientation(gluqo, o->otype==OBJ_CUP | o->otype==OBJ_TUBE ?
# Line 263 | Line 288 | register OBJREC *o;
288          gluCylinder(gluqo, o->oargs.farg[6], o->oargs.farg[iscyl ? 6 : 7],
289                          h, NSLICES, 1);
290          glPopMatrix();
291 <        rgl_checkerr("creating cone");
291 >        return(0);
292   }
293  
294  
295 + int
296   o_ring(o)                       /* convert a ring */
297   register OBJREC *o;
298   {
299          double  x1, y1, d;
300  
301          if (o->oargs.nfargs != 8)
302 <                objerror(o, "bad # real arguments");
302 >                objerror(o, USER, "bad # real arguments");
303          if (o->oargs.farg[7] < o->oargs.farg[6]) {
304                  register double d = o->oargs.farg[7];
305                  o->oargs.farg[7] = o->oargs.farg[6];
# Line 286 | Line 312 | register OBJREC        *o;
312          if (o->oargs.farg[7] - o->oargs.farg[6] <= FTINY)
313                  return;
314          if (dolights)
315 <                doflatsrc(o->os, o->oargs.farg, o->oargs.farg+3,
315 >                doflatsrc((MATREC *)o->os, o->oargs.farg, o->oargs.farg+3,
316                                  PI*(o->oargs.farg[7]*o->oargs.farg[7] -
317                                          o->oargs.farg[6]*o->oargs.farg[6]));
318 <        setmaterial(o->os, o->oargs.farg, 0);
318 >        setmaterial((MATREC *)o->os, o->oargs.farg, 0);
319          if (gluqo == NULL) newquadric();
320          glu_rout = "making disk";
321          gluQuadricOrientation(gluqo, GLU_OUTSIDE);
# Line 312 | Line 338 | register OBJREC        *o;
338                  glRotated(d, (GLdouble)x1, (GLdouble)y1, 0.);
339          gluDisk(gluqo, o->oargs.farg[6], o->oargs.farg[7], NSLICES, 1);
340          glPopMatrix();
341 <        rgl_checkerr("creating ring");
341 >        return(0);
342   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines