8 |
|
* Program to display Radiance scene using OpenGL. |
9 |
|
*/ |
10 |
|
|
11 |
– |
#include "radogl.h" |
12 |
– |
#include "view.h" |
13 |
– |
#include "paths.h" |
11 |
|
#include <sys/types.h> |
12 |
|
#include <GL/glx.h> |
13 |
|
#ifndef NOSTEREO |
14 |
|
#include <X11/extensions/SGIStereo.h> |
15 |
|
#endif |
16 |
|
#include <ctype.h> |
17 |
+ |
#include "radogl.h" |
18 |
+ |
#include "view.h" |
19 |
+ |
#include "paths.h" |
20 |
|
#include "glradicon.h" |
21 |
|
|
22 |
|
#ifndef MAXVIEW |
33 |
|
#define MOVDEG (-5) /* degrees to orbit CW/down /frame */ |
34 |
|
#define MOVORB(s) ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0) |
35 |
|
|
36 |
– |
#define MINWIDTH 480 /* minimum graphics window width */ |
37 |
– |
#define MINHEIGHT 400 /* minimum graphics window height */ |
38 |
– |
|
36 |
|
#define BORWIDTH 5 /* border width */ |
37 |
|
|
38 |
|
#define ourscreen DefaultScreen(ourdisplay) |
90 |
|
|
91 |
|
int displist; /* our scene display list */ |
92 |
|
|
93 |
< |
int in_dev_view = 0; /* currently in dev_view() */ |
93 |
> |
int no_render = 0; /* don't rerender */ |
94 |
|
|
95 |
|
#ifdef BSD |
96 |
|
#define strchr index |
173 |
|
/* all done */ |
174 |
|
quit(0); |
175 |
|
userr: |
176 |
< |
fprintf(stderr, "Usage: %s [-w][-b][-v view] rfile [VAR=value]..\n", |
176 |
> |
fprintf(stderr, |
177 |
> |
"Usage: %s [-w][-s][-b][-S][-v view] rfile [VAR=value]..\n", |
178 |
|
argv[0]); |
179 |
|
quit(1); |
180 |
|
} |
298 |
|
atof(sskip2(buf+4,1)), |
299 |
|
atof(sskip2(buf+4,2))); |
300 |
|
else if (backvis && !strncmp(buf, "-bv", 3) && |
301 |
< |
(!buf[3] || strchr(" 0-FfNn", buf[3]) != NULL)) |
301 |
> |
(!buf[3] || strchr("0-FfNn \n",buf[3])!=NULL)) |
302 |
|
backvis = 0; |
303 |
|
fclose(fp); |
304 |
|
unlink(optfile); /* delete options file */ |
372 |
|
GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE,15, None}; |
373 |
|
XSetWindowAttributes ourwinattr; |
374 |
|
XWMHints ourxwmhints; |
377 |
– |
XSizeHints oursizhints; |
375 |
|
/* open display server */ |
376 |
|
ourdisplay = XOpenDisplay(NULL); |
377 |
|
if (ourdisplay == NULL) |
418 |
|
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, |
419 |
|
gwind, glradicon_bits, glradicon_width, glradicon_height); |
420 |
|
XSetWMHints(ourdisplay, gwind, &ourxwmhints); |
424 |
– |
oursizhints.min_width = MINWIDTH; |
425 |
– |
oursizhints.min_height = stereo ? MINHEIGHT/2 : MINHEIGHT; |
426 |
– |
oursizhints.flags = PMinSize; |
427 |
– |
XSetNormalHints(ourdisplay, gwind, &oursizhints); |
421 |
|
/* set GLX context */ |
422 |
|
glXMakeCurrent(ourdisplay, gwind, gctx); |
423 |
|
glEnable(GL_DEPTH_TEST); |
424 |
|
glDepthFunc(GL_LESS); |
425 |
|
glShadeModel(GL_SMOOTH); |
426 |
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
427 |
< |
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
427 |
> |
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
428 |
|
glEnable(GL_LIGHTING); |
429 |
+ |
glFrontFace(GL_CCW); |
430 |
+ |
glCullFace(GL_BACK); |
431 |
|
if (backvis) |
432 |
|
glDisable(GL_CULL_FACE); |
433 |
< |
else { |
439 |
< |
glFrontFace(GL_CCW); |
440 |
< |
glCullFace(GL_BACK); |
433 |
> |
else |
434 |
|
glEnable(GL_CULL_FACE); |
442 |
– |
} |
435 |
|
glDrawBuffer(GL_BACK); |
436 |
|
/* figure out sensible view */ |
437 |
|
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
444 |
|
} |
445 |
|
/* map the window */ |
446 |
|
XMapWindow(ourdisplay, gwind); |
447 |
+ |
no_render++; |
448 |
|
do |
449 |
|
dev_input(0); /* get resize event */ |
450 |
|
while (hres == 0 & vres == 0); |
451 |
+ |
no_render--; |
452 |
|
rgl_checkerr("initializing GLX"); |
453 |
|
} |
454 |
|
|
499 |
|
} |
500 |
|
} |
501 |
|
if (newhres != hres | newvres != vres) { |
502 |
< |
in_dev_view++; |
502 |
> |
no_render++; |
503 |
|
XResizeWindow(ourdisplay, gwind, newhres, newvres); |
504 |
|
do |
505 |
|
dev_input(0); /* get resize event */ |
506 |
|
while (newhres != hres | newvres != vres); |
507 |
< |
in_dev_view--; |
507 |
> |
no_render--; |
508 |
|
} |
509 |
|
} |
510 |
|
copystruct(&thisview, nv); |
558 |
|
{ |
559 |
|
double d; |
560 |
|
|
561 |
< |
if (!mapped) |
561 |
> |
if (!mapped | no_render) |
562 |
|
return; |
563 |
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
564 |
|
glCallList(displist); |
809 |
|
; |
810 |
|
else if (vwnum >= MAXVIEW || vwl[vwnum].v == NULL) |
811 |
|
vwnum = 0; |
818 |
– |
if (vwnum == currentview) |
819 |
– |
return; |
812 |
|
copylastv("standard view"); |
813 |
|
dev_view(vwl[currentview=vwnum].v); |
814 |
|
} |
882 |
|
glViewport(0, 0, hres=ersz->width, vres=ersz->height); |
883 |
|
if (hres > maxhres) maxhres = hres; |
884 |
|
if (vres > maxvres) maxvres = vres; |
885 |
< |
if (in_dev_view) |
885 |
> |
if (no_render) |
886 |
|
return; |
887 |
|
wa = (vres*pheight)/(hres*pwidth); |
888 |
|
va = viewaspect(&thisview); |