5 |
|
* Geometry drawing operations for OpenGL driver. |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <string.h> |
9 |
+ |
|
10 |
+ |
#include "rtio.h" |
11 |
|
#include "radogl.h" |
12 |
|
#include "rhdriver.h" |
13 |
+ |
#include "rhd_odraw.h" |
14 |
|
|
15 |
|
#ifndef MAXGEO |
16 |
|
#define MAXGEO 8 /* maximum geometry list length */ |
27 |
|
static struct gmEntry { |
28 |
|
char *gfile; /* geometry file name */ |
29 |
|
FVECT cent; /* centroid */ |
30 |
< |
FLOAT rad; /* radius */ |
30 |
> |
RREAL rad; /* radius */ |
31 |
|
int listid; /* display list identifier */ |
32 |
|
int nlists; /* number of lists allocated */ |
33 |
|
} gmCurrent[MAXGEO], gmNext[MAXGEO]; /* current and next list */ |
36 |
|
|
37 |
|
#define FORALLPORT(pl,i) for (i=0;i<MAXPORT&&pl[i]!=NULL;i++) |
38 |
|
|
35 |
– |
extern char *nextword(); |
39 |
|
|
40 |
|
|
41 |
< |
gmNewGeom(file) /* add new geometry to next list */ |
42 |
< |
char *file; |
41 |
> |
|
42 |
> |
void |
43 |
> |
gmNewGeom( /* add new geometry to next list */ |
44 |
> |
char *file |
45 |
> |
) |
46 |
|
{ |
47 |
< |
register int i, j; |
47 |
> |
int i, j; |
48 |
|
/* check if already in next list */ |
49 |
|
FORALLGEOM(gmNext, i) |
50 |
|
if (!strcmp(file, gmNext[i].gfile)) |
56 |
|
/* check if copy in current list */ |
57 |
|
FORALLGEOM(gmCurrent, j) |
58 |
|
if (!strcmp(file, gmCurrent[j].gfile)) { |
59 |
< |
copystruct(&gmNext[i], &gmCurrent[j]); |
59 |
> |
gmNext[i] = gmCurrent[j]; |
60 |
|
return; |
61 |
|
} |
62 |
|
/* else load new octree */ |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
< |
gmEndGeom() /* make next list current */ |
76 |
> |
void |
77 |
> |
gmEndGeom(void) /* make next list current */ |
78 |
|
{ |
79 |
< |
register int i, j; |
79 |
> |
int i, j; |
80 |
|
|
81 |
|
FORALLGEOM(gmCurrent, i) { |
82 |
|
FORALLGEOM(gmNext, j) |
88 |
|
freestr(gmCurrent[i].gfile); |
89 |
|
} |
90 |
|
} |
91 |
< |
bcopy((void *)gmNext, (void *)gmCurrent, sizeof(gmNext)); |
92 |
< |
bzero((void *)gmNext, sizeof(gmNext)); |
91 |
> |
memcpy((void *)gmCurrent, (void *)gmNext, sizeof(gmNext)); |
92 |
> |
memset((void *)gmNext, '\0', sizeof(gmNext)); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
int |
97 |
< |
gmDrawGeom() /* draw current list of octrees */ |
97 |
> |
gmDrawGeom(void) /* draw current list of octrees */ |
98 |
|
{ |
99 |
< |
register int n; |
99 |
> |
int n; |
100 |
|
|
101 |
|
FORALLGEOM(gmCurrent, n) |
102 |
|
glCallList(gmCurrent[n].listid); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
< |
gmDrawPortals(r, g, b, a) /* draw portals with specific RGBA value */ |
108 |
< |
int r, g, b, a; |
107 |
> |
void |
108 |
> |
gmDrawPortals( /* draw portals with specific RGBA value */ |
109 |
> |
int r, |
110 |
> |
int g, |
111 |
> |
int b, |
112 |
> |
int a |
113 |
> |
) |
114 |
|
{ |
115 |
< |
if (!gmPortals || r<0 & g<0 & b<0 & a<0) |
115 |
> |
if (!gmPortals || (r<0) & (g<0) & (b<0) & (a<0)) |
116 |
|
return; |
117 |
|
glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT| |
118 |
|
GL_POLYGON_BIT|GL_LIGHTING_BIT); |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
< |
gmDepthLimit(dl, vorg, vdir) /* compute approximate depth limits for view */ |
134 |
< |
double dl[2]; |
135 |
< |
FVECT vorg, vdir; |
133 |
> |
void |
134 |
> |
gmDepthLimit( /* compute approximate depth limits for view */ |
135 |
> |
double dl[2], |
136 |
> |
FVECT vorg, |
137 |
> |
FVECT vdir |
138 |
> |
) |
139 |
|
{ |
140 |
|
FVECT v; |
141 |
|
double dcent; |
142 |
< |
register int i; |
142 |
> |
int i; |
143 |
|
|
144 |
|
dl[0] = FHUGE; dl[1] = 0.; |
145 |
|
FORALLGEOM(gmCurrent, i) { |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
< |
gmNewPortal(pflist) /* add portal file(s) to our new list */ |
159 |
< |
char *pflist; |
158 |
> |
void |
159 |
> |
gmNewPortal( /* add portal file(s) to our new list */ |
160 |
> |
char *pflist |
161 |
> |
) |
162 |
|
{ |
163 |
< |
register int i, j; |
163 |
> |
int i; |
164 |
|
char newfile[128]; |
165 |
|
|
166 |
|
if (pflist == NULL) |
188 |
|
|
189 |
|
|
190 |
|
int |
191 |
< |
gmEndPortal() /* close portal list and return GL list */ |
191 |
> |
gmEndPortal(void) /* close portal list and return GL list */ |
192 |
|
{ |
193 |
< |
register int n; |
193 |
> |
int n; |
194 |
|
|
195 |
|
FORALLPORT(newportlist, n); |
196 |
|
if (!n) { /* free old GL list */ |
213 |
|
} |
214 |
|
FORALLPORT(curportlist, n) /* free old file list */ |
215 |
|
freestr(curportlist[n]); |
216 |
< |
bcopy((void *)newportlist, (void *)curportlist, sizeof(newportlist)); |
217 |
< |
bzero((void *)newportlist, sizeof(newportlist)); |
216 |
> |
memcpy((void *)curportlist, (void *)newportlist, sizeof(newportlist)); |
217 |
> |
memset((void *)newportlist, '\0', sizeof(newportlist)); |
218 |
|
return(gmPortals); /* return GL list id */ |
219 |
|
} |