37 |
|
#include "x11icon.h" |
38 |
|
|
39 |
|
#ifndef RAYQLEN |
40 |
< |
#define RAYQLEN 10240 /* max. rays to queue before flush */ |
40 |
> |
#define RAYQLEN 50000 /* max. rays to queue before flush */ |
41 |
|
#endif |
42 |
|
|
43 |
|
#ifndef PORTALP |
142 |
|
extern char *getenv(); |
143 |
|
static RGBPRIMS myprims = STDPRIMS; |
144 |
|
#if (PORTALP<0) |
145 |
< |
static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8, |
146 |
< |
GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, |
147 |
< |
GLX_DEPTH_SIZE,15, None}; |
145 |
> |
static int atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
146 |
> |
GLX_RED_SIZE,8, GLX_GREEN_SIZE,8, |
147 |
> |
GLX_BLUE_SIZE,8, GLX_DEPTH_SIZE,15, None}; |
148 |
> |
static int atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
149 |
> |
GLX_RED_SIZE,4, GLX_GREEN_SIZE,4, |
150 |
> |
GLX_BLUE_SIZE,4, GLX_DEPTH_SIZE,15, None}; |
151 |
|
#else |
152 |
< |
static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8, |
153 |
< |
GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, |
154 |
< |
GLX_ALPHA_SIZE,2, GLX_DEPTH_SIZE,15, None}; |
152 |
> |
static int atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
153 |
> |
GLX_RED_SIZE,8, GLX_GREEN_SIZE,8, |
154 |
> |
GLX_BLUE_SIZE,8, GLX_ALPHA_SIZE,2, |
155 |
> |
GLX_DEPTH_SIZE,15, None}; |
156 |
> |
static int atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
157 |
> |
GLX_RED_SIZE,4, GLX_GREEN_SIZE,4, |
158 |
> |
GLX_BLUE_SIZE,4, GLX_ALPHA_SIZE,2, |
159 |
> |
GLX_DEPTH_SIZE,15, None}; |
160 |
|
#endif |
161 |
|
char *ev; |
162 |
|
double gamval = GAMMA; |
170 |
|
#endif |
171 |
|
/* open display server */ |
172 |
|
ourdisplay = XOpenDisplay(NULL); |
173 |
< |
if (ourdisplay == NULL) |
174 |
< |
error(USER, "cannot open X-windows; DISPLAY variable set?\n"); |
173 |
> |
CHECK(ourdisplay==NULL, USER, |
174 |
> |
"cannot open X-windows; DISPLAY variable set?"); |
175 |
|
#ifdef STEREO |
176 |
|
switch (XSGIQueryStereoMode(ourdisplay, ourroot)) { |
177 |
|
case STEREO_TOP: |
179 |
|
break; |
180 |
|
case STEREO_OFF: |
181 |
|
error(USER, |
182 |
< |
"wrong video mode: run \"/usr/gfx/setmon -n STR_TOP\" first"); |
182 |
> |
"wrong video mode: run \"/usr/gfx/setmon -n STR_TOP\" first"); |
183 |
|
case X_STEREO_UNSUPPORTED: |
184 |
|
error(USER, "stereo mode not supported on this screen"); |
185 |
|
default: |
189 |
|
/* find a usable visual */ |
190 |
|
ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlBest); |
191 |
|
if (ourvinf == NULL) |
192 |
< |
error(USER, "no suitable visuals available"); |
192 |
> |
ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlOK); |
193 |
> |
CHECK(ourvinf==NULL, USER, "no suitable visuals available"); |
194 |
|
/* get a context */ |
195 |
|
gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE); |
196 |
|
/* set gamma and tone mapping */ |
222 |
|
#endif |
223 |
|
BORWIDTH, ourvinf->depth, InputOutput, ourvinf->visual, |
224 |
|
CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &ourwinattr); |
225 |
< |
if (gwind == 0) |
217 |
< |
error(SYSTEM, "cannot create window\n"); |
225 |
> |
CHECK(gwind==0, SYSTEM, "cannot create window"); |
226 |
|
XStoreName(ourdisplay, gwind, id); |
227 |
|
/* set window manager hints */ |
228 |
|
ourxwmhints.flags = InputHint|IconPixmapHint; |
246 |
|
glXMakeCurrent(ourdisplay, gwind, gctx); |
247 |
|
glEnable(GL_DEPTH_TEST); |
248 |
|
glDepthFunc(GL_LEQUAL); |
249 |
< |
glDisable(GL_DITHER); |
249 |
> |
glEnable(GL_DITHER); |
250 |
|
glFrontFace(GL_CCW); |
251 |
|
glDisable(GL_CULL_FACE); |
252 |
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
355 |
|
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
356 |
|
/* setview(&vwright); -- Unnecessary */ |
357 |
|
#endif |
358 |
< |
} else |
351 |
< |
viewsteady = 1; |
358 |
> |
} |
359 |
|
wipeclean(); |
360 |
|
return(1); |
361 |
|
} |
458 |
|
#ifdef DOBJ |
459 |
|
ndrawn += dobj_render(); |
460 |
|
#endif |
461 |
< |
if (ndrawn) |
462 |
< |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
461 |
> |
if (ndrawn && gmPortals) |
462 |
> |
gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP); |
463 |
|
checkglerr("rendering right eye"); |
464 |
|
popright(); /* draw left eye */ |
465 |
|
#endif |
467 |
|
#ifdef DOBJ |
468 |
|
ndrawn += dobj_render(); |
469 |
|
#endif |
470 |
< |
if (ndrawn) |
471 |
< |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
470 |
> |
if (ndrawn && gmPortals) |
471 |
> |
gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP); |
472 |
> |
glXSwapBuffers(ourdisplay, gwind); |
473 |
|
checkglerr("rendering base view"); |
474 |
|
} |
475 |
|
if (mapped && viewsteady) |
484 |
|
popright(); |
485 |
|
#endif |
486 |
|
odUpdate(0); /* draw left eye */ |
487 |
+ |
glFlush(); /* flush OpenGL */ |
488 |
|
} |
480 |
– |
glFlush(); /* flush OpenGL */ |
489 |
|
rayqleft = RAYQLEN; |
490 |
|
/* flush X11 and return # pending */ |
491 |
|
return(odev.inpready = XPending(ourdisplay)); |
518 |
|
#endif |
519 |
|
depthbuffer = (GLfloat *)malloc( |
520 |
|
odev.hres*odev.vres*sizeof(GLfloat)); |
521 |
< |
if (depthbuffer == NULL) |
514 |
< |
error(SYSTEM, "out of memory in xferdepth"); |
521 |
> |
CHECK(depthbuffer==NULL, SYSTEM, "out of memory in xferdepth"); |
522 |
|
} |
523 |
|
/* allocate alpha buffer for portals */ |
524 |
|
if (gmPortals) |
525 |
< |
cbuf = (GLubyte *)malloc(odev.hres*odev.vres* |
525 |
> |
cbuf = (GLubyte *)malloc(odev.hres*odev.vres * |
526 |
|
(4*sizeof(GLubyte))); |
527 |
|
else |
528 |
|
cbuf = NULL; |
831 |
|
#ifdef DOBJ |
832 |
|
ndrawn += dobj_render(); |
833 |
|
#endif |
834 |
< |
if (ndrawn) |
835 |
< |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
834 |
> |
if (ndrawn && gmPortals) |
835 |
> |
gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP); |
836 |
|
popright(); |
837 |
|
#endif |
838 |
|
/* redraw octrees */ |
840 |
|
#ifdef DOBJ |
841 |
|
ndrawn += dobj_render(); /* redraw objects */ |
842 |
|
#endif |
843 |
< |
if (ndrawn) |
843 |
> |
if (ndrawn && gmPortals) |
844 |
|
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
845 |
< |
glFlush(); |
846 |
< |
if (!ndrawn) { |
845 |
> |
glXSwapBuffers(ourdisplay, gwind); |
846 |
> |
if (!ndrawn) |
847 |
|
sleep(1); /* for reasonable interaction */ |
841 |
– |
#ifdef STEREO |
842 |
– |
pushright(); |
843 |
– |
draw_grids(0); |
844 |
– |
popright(); |
845 |
– |
#endif |
846 |
– |
draw_grids(0); |
847 |
– |
} |
848 |
|
} |
849 |
|
if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */ |
850 |
|
movdir = MOVDIR(levptr(XButtonReleasedEvent)->button); |
852 |
|
wy = levptr(XButtonReleasedEvent)->y; |
853 |
|
moveview(wx, odev.vres-1-wy, movdir, movorb); |
854 |
|
} |
855 |
+ |
viewsteady = 1; /* done goofing around */ |
856 |
|
} |
857 |
|
|
858 |
|
|
921 |
|
static |
922 |
|
setglortho() /* set up orthographic view for cone drawing */ |
923 |
|
{ |
924 |
+ |
glDrawBuffer(GL_FRONT); /* use single-buffer mode */ |
925 |
|
/* set view matrix */ |
926 |
|
glMatrixMode(GL_PROJECTION); |
927 |
|
glLoadIdentity(); |
937 |
|
static |
938 |
|
wipeclean() /* prepare for redraw */ |
939 |
|
{ |
940 |
< |
/* clear depth buffer */ |
940 |
> |
glDrawBuffer(GL_BACK); /* use double-buffer mode */ |
941 |
> |
/* clear buffers */ |
942 |
|
#ifdef STEREO |
943 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
944 |
< |
glClear(GL_DEPTH_BUFFER_BIT); |
944 |
> |
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
945 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
946 |
|
#endif |
947 |
< |
glClear(GL_DEPTH_BUFFER_BIT); |
947 |
> |
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
948 |
> |
freedepth(); |
949 |
|
if (viewsteady) /* clear samples if steady */ |
950 |
|
odClean(); |
947 |
– |
freedepth(); |
951 |
|
setglpersp(&odev.v); /* reset view & clipping planes */ |
952 |
|
} |
953 |
|
|
999 |
|
return; |
1000 |
|
case CTRL('R'): /* redraw screen */ |
1001 |
|
odRemap(0); |
1002 |
< |
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
1002 |
> |
glClear(GL_DEPTH_BUFFER_BIT); |
1003 |
|
#ifdef STEREO |
1004 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
1005 |
< |
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
1005 |
> |
glClear(GL_DEPTH_BUFFER_BIT); |
1006 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
1007 |
|
#endif |
1008 |
|
return; |