--- ray/src/common/rglfile.c 1998/08/17 17:57:59 3.2 +++ ray/src/common/rglfile.c 2004/03/28 20:33:12 3.11 @@ -1,30 +1,28 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rglfile.c,v 3.11 2004/03/28 20:33:12 schorsch Exp $"; #endif - /* * Load Radiance object(s) and create OpenGL display lists */ +#include "copyright.h" + +#include + +#include "rtprocess.h" #include "radogl.h" #ifndef NLIST2ALLOC #define NLIST2ALLOC 16 /* batch of display lists to get */ #endif -extern int o_sphere(), o_face(), o_cone(), o_ring(), - o_source(), o_instance(); - -extern int m_normal(), m_glass(), m_aniso(), m_brdf(), m_brdf2(), - m_light(), m_prism(), m_mirror(); - FUN ofun[NUMOTYPE] = INIT_OTYPE; +static int nextlist, nlistleft = 0; -static -initotypes() /* initialize ofun array */ + +void +initotypes(void) /* initialize ofun array */ { if (ofun[OBJ_SPHERE].funp == o_sphere) return; /* already done */ @@ -39,6 +37,7 @@ initotypes() /* initialize ofun array */ ofun[OBJ_RING].funp = o_ring; ofun[OBJ_SOURCE].funp = o_source; ofun[OBJ_INSTANCE].funp = o_instance; + ofun[OBJ_MESH].funp = o_unsupported; /* assign material types */ ofun[MAT_TRANS].funp = ofun[MAT_PLASTIC].funp = @@ -69,16 +68,17 @@ initotypes() /* initialize ofun array */ int newglist() /* allocate an OGL list id */ { - static int nextlist, nleft = 0; - - if (!nleft--) { + if (!nlistleft--) { nextlist = glGenLists(NLIST2ALLOC); - nleft = NLIST2ALLOC-1; + if (!nextlist) + error(SYSTEM, "no list space left in newglist"); + nlistleft = NLIST2ALLOC-1; } return(nextlist++); } +void rgl_checkerr(where) /* check for GL or GLU error */ char *where; { @@ -93,9 +93,10 @@ char *where; int -rgl_filelist(ic, inp) /* load scene files into display list */ +rgl_filelist(ic, inp, nl) /* load scene files into display list */ int ic; char **inp; +int *nl; /* returned number of lists (optional) */ { int listid; @@ -110,15 +111,18 @@ char **inp; glEndList(); /* end of top display list */ lightdefs(); /* define light sources */ loadoctrees(); /* load octrees (sublists) for instances */ + if (nl != NULL) /* return total number of lists allocated */ + *nl = nextlist - listid; return(listid); /* all done -- return list id */ } int -rgl_octlist(fname, cent, radp) /* load octree objects into display list */ +rgl_octlist(fname, cent, radp, nl) /* load scen into display list */ char *fname; FVECT cent; /* returned octree center (optional) */ -FLOAT *radp; /* returned octree size (optional) */ +RREAL *radp; /* returned octree size (optional) */ +int *nl; /* returned number of lists (optional) */ { double r; int listid; @@ -137,14 +141,16 @@ FLOAT *radp; /* returned octree size (optional) */ glEndList(); /* close top list */ lightdefs(); /* define light sources */ loadoctrees(); /* load referenced octrees into sublists */ + if (nl != NULL) /* return total number of lists allocated */ + *nl = nextlist - listid; return(listid); } +void rgl_load(inpspec) /* convert scene description into OGL calls */ char *inpspec; { - FILE *popen(); char *fgetline(); FILE *infp; char buf[1024]; @@ -183,6 +189,7 @@ char *inpspec; } +void rgl_object(name, fp) /* read the next object */ char *name; FILE *fp; @@ -194,16 +201,14 @@ FILE *fp; strcpy(sbuf, "EOF"); fgetword(sbuf, MAXSTR, fp); ob.omod = 0; /* use ob.os for pointer to material */ - if (!strcmp(sbuf, VOIDID)) + if (!strcmp(sbuf, VOIDID) || !strcmp(sbuf, ALIASMOD)) ob.os = NULL; else ob.os = (char *)getmatp(sbuf); /* get type */ strcpy(sbuf, "EOF"); fgetword(sbuf, MAXSTR, fp); - if (!strcmp(sbuf, ALIASID)) - ob.otype = -1; - else if ((ob.otype = otype(sbuf)) < 0) { + if ((ob.otype = otype(sbuf)) < 0) { sprintf(errmsg, "(%s): unknown type \"%s\"", name, sbuf); error(USER, errmsg); } @@ -212,7 +217,7 @@ FILE *fp; fgetword(sbuf, MAXSTR, fp); ob.oname = sbuf; /* get arguments */ - if (ob.otype == -1) { + if (ob.otype == MOD_ALIAS) { char sbuf2[MAXSTR]; /* get alias */ strcpy(sbuf2, "EOF"); fgetword(sbuf2, MAXSTR, fp);