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 |
|
* Program to display Radiance scene using OpenGL. |
6 |
|
*/ |
7 |
|
|
11 |
– |
#include "radogl.h" |
12 |
– |
#include "view.h" |
13 |
– |
#include "paths.h" |
8 |
|
#include <sys/types.h> |
9 |
|
#include <GL/glx.h> |
10 |
|
#ifndef NOSTEREO |
11 |
|
#include <X11/extensions/SGIStereo.h> |
12 |
|
#endif |
13 |
|
#include <ctype.h> |
14 |
+ |
#include <time.h> |
15 |
+ |
#include "radogl.h" |
16 |
+ |
#include "view.h" |
17 |
+ |
#include "paths.h" |
18 |
|
#include "glradicon.h" |
19 |
|
|
20 |
|
#ifndef MAXVIEW |
90 |
|
|
91 |
|
int no_render = 0; /* don't rerender */ |
92 |
|
|
93 |
< |
#ifdef BSD |
96 |
< |
#define strchr index |
97 |
< |
#endif |
98 |
< |
|
99 |
< |
extern char *strchr(), *fgets(), *fgetline(), *atos(), *scan4var(); |
93 |
> |
extern char *fgetline(), *atos(), *scan4var(); |
94 |
|
extern int nowarn; /* turn warnings off? */ |
101 |
– |
extern time_t time(); |
95 |
|
|
96 |
|
|
97 |
|
main(argc, argv) |
154 |
|
dev_open(radfile = argv[i]); |
155 |
|
/* load octree or scene files */ |
156 |
|
if (octree != NULL) { |
157 |
< |
displist = rgl_octlist(octree, NULL, NULL); |
157 |
> |
displist = rgl_octlist(octree, NULL, NULL, NULL); |
158 |
|
startrtrace(octree); |
159 |
|
} else |
160 |
< |
displist = rgl_filelist(nscenef, scene); |
160 |
> |
displist = rgl_filelist(nscenef, scene, NULL); |
161 |
|
/* set initial view */ |
162 |
|
dev_view(currentview < 0 ? &thisview : vwl[currentview].v); |
163 |
|
/* input/render loop */ |
166 |
|
/* all done */ |
167 |
|
quit(0); |
168 |
|
userr: |
169 |
< |
fprintf(stderr, "Usage: %s [-w][-b][-v view] rfile [VAR=value]..\n", |
169 |
> |
fprintf(stderr, |
170 |
> |
"Usage: %s [-w][-s][-b][-S][-v view] rfile [VAR=value]..\n", |
171 |
|
argv[0]); |
172 |
|
quit(1); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
+ |
void |
177 |
|
quit(code) /* exit gracefully */ |
178 |
|
int code; |
179 |
|
{ |
292 |
|
atof(sskip2(buf+4,1)), |
293 |
|
atof(sskip2(buf+4,2))); |
294 |
|
else if (backvis && !strncmp(buf, "-bv", 3) && |
295 |
< |
(!buf[3] || strchr(" 0-FfNn", buf[3]) != NULL)) |
295 |
> |
(!buf[3] || strchr("0-FfNn \n",buf[3])!=NULL)) |
296 |
|
backvis = 0; |
297 |
|
fclose(fp); |
298 |
|
unlink(optfile); /* delete options file */ |
418 |
|
glDepthFunc(GL_LESS); |
419 |
|
glShadeModel(GL_SMOOTH); |
420 |
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
421 |
< |
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
421 |
> |
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
422 |
|
glEnable(GL_LIGHTING); |
423 |
+ |
glFrontFace(GL_CCW); |
424 |
+ |
glCullFace(GL_BACK); |
425 |
|
if (backvis) |
426 |
|
glDisable(GL_CULL_FACE); |
427 |
< |
else { |
431 |
< |
glFrontFace(GL_CCW); |
432 |
< |
glCullFace(GL_BACK); |
427 |
> |
else |
428 |
|
glEnable(GL_CULL_FACE); |
434 |
– |
} |
429 |
|
glDrawBuffer(GL_BACK); |
430 |
|
/* figure out sensible view */ |
431 |
|
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
620 |
|
} |
621 |
|
|
622 |
|
|
623 |
+ |
static |
624 |
+ |
waitabit() /* pause a moment */ |
625 |
+ |
{ |
626 |
+ |
struct timespec ts; |
627 |
+ |
ts.tv_sec = 0; |
628 |
+ |
ts.tv_nsec = 5000000; |
629 |
+ |
nanosleep(&ts, NULL); |
630 |
+ |
} |
631 |
+ |
|
632 |
+ |
|
633 |
|
getmove(ebut) /* get view change */ |
634 |
|
XButtonPressedEvent *ebut; |
635 |
|
{ |
646 |
|
|
647 |
|
while (!XCheckMaskEvent(ourdisplay, |
648 |
|
ButtonReleaseMask, levptr(XEvent))) { |
649 |
+ |
/* pause so as not to move too fast */ |
650 |
+ |
waitabit(); |
651 |
|
|
652 |
|
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
653 |
|
&rootx, &rooty, &wx, &wy, &statemask)) |
683 |
|
if (md <= FTINY) md = FHUGE; |
684 |
|
fbuf[3] = dir[0]*md; fbuf[4] = dir[1]*md; fbuf[5] = dir[2]*md; |
685 |
|
/* trace that ray */ |
686 |
< |
if (process(rtpd, fbuf, fbuf, 4*sizeof(float), 6*sizeof(float)) != |
687 |
< |
4*sizeof(float)) |
686 |
> |
if (process(rtpd, (char *)fbuf, (char *)fbuf, |
687 |
> |
4*sizeof(float), 6*sizeof(float)) != 4*sizeof(float)) |
688 |
|
error(INTERNAL, "error getting data back from rtrace process"); |
689 |
|
if (fbuf[3] >= .99*FHUGE) |
690 |
|
return(0); /* missed local objects */ |