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 "radogl.h" |
11 |
|
|
12 |
|
#ifndef NLIST2ALLOC |
13 |
|
#define NLIST2ALLOC 16 /* batch of display lists to get */ |
14 |
|
#endif |
15 |
|
|
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 |
– |
|
16 |
|
FUN ofun[NUMOTYPE] = INIT_OTYPE; |
17 |
|
|
18 |
+ |
static int nextlist, nlistleft = 0; |
19 |
|
|
20 |
< |
static |
20 |
> |
|
21 |
> |
static void |
22 |
|
initotypes() /* initialize ofun array */ |
23 |
|
{ |
24 |
|
if (ofun[OBJ_SPHERE].funp == o_sphere) |
64 |
|
int |
65 |
|
newglist() /* allocate an OGL list id */ |
66 |
|
{ |
67 |
< |
static int nextlist, nleft = 0; |
73 |
< |
|
74 |
< |
if (!nleft--) { |
67 |
> |
if (!nlistleft--) { |
68 |
|
nextlist = glGenLists(NLIST2ALLOC); |
69 |
< |
nleft = NLIST2ALLOC-1; |
69 |
> |
if (!nextlist) |
70 |
> |
error(SYSTEM, "no list space left in newglist"); |
71 |
> |
nlistleft = NLIST2ALLOC-1; |
72 |
|
} |
73 |
|
return(nextlist++); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
+ |
void |
78 |
|
rgl_checkerr(where) /* check for GL or GLU error */ |
79 |
|
char *where; |
80 |
|
{ |
89 |
|
|
90 |
|
|
91 |
|
int |
92 |
< |
rgl_filelist(ic, inp) /* load scene files into display list */ |
92 |
> |
rgl_filelist(ic, inp, nl) /* load scene files into display list */ |
93 |
|
int ic; |
94 |
|
char **inp; |
95 |
+ |
int *nl; /* returned number of lists (optional) */ |
96 |
|
{ |
97 |
|
int listid; |
98 |
|
|
107 |
|
glEndList(); /* end of top display list */ |
108 |
|
lightdefs(); /* define light sources */ |
109 |
|
loadoctrees(); /* load octrees (sublists) for instances */ |
110 |
+ |
if (nl != NULL) /* return total number of lists allocated */ |
111 |
+ |
*nl = nextlist - listid; |
112 |
|
return(listid); /* all done -- return list id */ |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
int |
117 |
< |
rgl_octlist(fname, cent, radp) /* load octree objects into display list */ |
117 |
> |
rgl_octlist(fname, cent, radp, nl) /* load scen into display list */ |
118 |
|
char *fname; |
119 |
|
FVECT cent; /* returned octree center (optional) */ |
120 |
|
FLOAT *radp; /* returned octree size (optional) */ |
121 |
+ |
int *nl; /* returned number of lists (optional) */ |
122 |
|
{ |
123 |
|
double r; |
124 |
|
int listid; |
137 |
|
glEndList(); /* close top list */ |
138 |
|
lightdefs(); /* define light sources */ |
139 |
|
loadoctrees(); /* load referenced octrees into sublists */ |
140 |
+ |
if (nl != NULL) /* return total number of lists allocated */ |
141 |
+ |
*nl = nextlist - listid; |
142 |
|
return(listid); |
143 |
|
} |
144 |
|
|
145 |
|
|
146 |
+ |
void |
147 |
|
rgl_load(inpspec) /* convert scene description into OGL calls */ |
148 |
|
char *inpspec; |
149 |
|
{ |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
+ |
void |
190 |
|
rgl_object(name, fp) /* read the next object */ |
191 |
|
char *name; |
192 |
|
FILE *fp; |