| 10 |
|
*/ |
| 11 |
|
|
| 12 |
|
#include "standard.h" |
| 13 |
< |
#include "tonemap.h" |
| 14 |
< |
#include "rhdriver.h" |
| 13 |
> |
#include "rhd_qtree.h" |
| 14 |
|
|
| 15 |
|
#include <GL/glx.h> |
| 16 |
|
|
| 20 |
|
#define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) |
| 21 |
|
#endif |
| 22 |
|
|
| 23 |
< |
#ifndef int4 |
| 24 |
< |
#define int4 int |
| 23 |
> |
#ifndef MAXCONE |
| 24 |
> |
#define MAXCONE 16 /* number of different cone sizes */ |
| 25 |
|
#endif |
| 26 |
< |
|
| 27 |
< |
#ifndef FREEPCT |
| 29 |
< |
#define FREEPCT 10 /* percentage of values to free */ |
| 26 |
> |
#ifndef MAXVERT |
| 27 |
> |
#define MAXVERT 32 /* maximum number of cone vertices */ |
| 28 |
|
#endif |
| 29 |
< |
|
| 30 |
< |
#ifndef NCONEV |
| 33 |
< |
#define NCONEV 7 /* number of cone base vertices */ |
| 29 |
> |
#ifndef MINVERT |
| 30 |
> |
#define MINVERT 4 /* minimum number of cone vertices */ |
| 31 |
|
#endif |
| 32 |
< |
#ifndef CONEH |
| 33 |
< |
#define CONEH 3. /* cone height (fraction of depth) */ |
| 32 |
> |
#ifndef DEPTHFACT |
| 33 |
> |
#define DEPTHFACT 16. /* multiplier for depth tests */ |
| 34 |
|
#endif |
| 38 |
– |
#ifndef CONEW |
| 39 |
– |
#define CONEW 0.05 /* cone width (fraction of screen) */ |
| 40 |
– |
#endif |
| 41 |
– |
#ifndef DIRPEN |
| 42 |
– |
#define DIRPEN 0.001 /* direction penalty factor */ |
| 43 |
– |
#endif |
| 44 |
– |
#ifndef VALUA |
| 45 |
– |
#define VALUA 16 /* target value area (pixels) */ |
| 46 |
– |
#endif |
| 35 |
|
|
| 36 |
|
#define GAMMA 1.4 /* default gamma correction */ |
| 37 |
|
|
| 66 |
|
static Window gwind = 0; /* our graphics window */ |
| 67 |
|
static GLXContext gctx; /* our GLX context */ |
| 68 |
|
|
| 81 |
– |
static double mindepth = FHUGE; /* minimum depth value so far */ |
| 82 |
– |
static double maxdepth = 0.; /* maximum depth value so far */ |
| 83 |
– |
|
| 69 |
|
static double pwidth, pheight; /* pixel dimensions (mm) */ |
| 70 |
|
|
| 71 |
< |
static FVECT conev[NCONEV]; /* drawing cone */ |
| 72 |
< |
static double coneh; /* cone height */ |
| 71 |
> |
static double curzmax = 1e4; /* current depth upper limit */ |
| 72 |
> |
static double nxtzmax = 0.; /* maximum (finite) depth so far */ |
| 73 |
|
|
| 74 |
+ |
static struct { |
| 75 |
+ |
double rad; /* cone radius */ |
| 76 |
+ |
int nverts; /* number of vertices */ |
| 77 |
+ |
FVECT *va; /* allocated vertex array */ |
| 78 |
+ |
} cone[MAXCONE]; /* precomputed cones for drawing */ |
| 79 |
+ |
|
| 80 |
|
static int inpresflags; /* input result flags */ |
| 81 |
|
|
| 82 |
|
static int headlocked = 0; /* lock vertical motion */ |
| 83 |
|
|
| 93 |
– |
static int quicken = 0; /* quicker, sloppier update rate? */ |
| 94 |
– |
|
| 95 |
– |
static struct { |
| 96 |
– |
float (*wp)[3]; /* world intersection point array */ |
| 97 |
– |
int4 *wd; /* world direction array */ |
| 98 |
– |
TMbright *brt; /* encoded brightness array */ |
| 99 |
– |
BYTE (*chr)[3]; /* encoded chrominance array */ |
| 100 |
– |
BYTE (*rgb)[3]; /* tone-mapped color array */ |
| 101 |
– |
BYTE *alpha; /* alpha values */ |
| 102 |
– |
int nl; /* count of values */ |
| 103 |
– |
int bl, tl; /* bottom and top (next) value index */ |
| 104 |
– |
int tml; /* next value needing tone-mapping */ |
| 105 |
– |
int drl; /* next value in need of drawing */ |
| 106 |
– |
char *base; /* base of allocated memory */ |
| 107 |
– |
} rV; /* our collection of values */ |
| 108 |
– |
|
| 109 |
– |
static int *valmap = NULL; /* sorted map of screen values */ |
| 110 |
– |
static int vmaplen = 0; /* value map length */ |
| 111 |
– |
|
| 112 |
– |
#define redraw() (rV.drl = rV.bl) |
| 113 |
– |
|
| 84 |
|
static int resizewindow(), getevent(), getkey(), moveview(), |
| 85 |
< |
setGLview(), getmove(), fixwindow(), mytmflags(), |
| 86 |
< |
drawvalue(), valcmp(), clralphas(), setalphas(), mergalphas(), |
| 117 |
< |
IndexValue(), Compost(), FindValue(), TMapValues(), |
| 118 |
< |
AllocValues(), FreeValues(); |
| 85 |
> |
initcones(), freecones(), |
| 86 |
> |
getmove(), fixwindow(), mytmflags(); |
| 87 |
|
|
| 120 |
– |
extern int4 encodedir(); |
| 121 |
– |
extern double fdir2diff(), dir2diff(); |
| 88 |
|
|
| 123 |
– |
|
| 89 |
|
dev_open(id) /* initialize X11 driver */ |
| 90 |
|
char *id; |
| 91 |
|
{ |
| 92 |
|
extern char *getenv(); |
| 93 |
|
static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8, |
| 94 |
|
GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, |
| 95 |
< |
GLX_ALPHA_SIZE,8, GLX_DEPTH_SIZE,15, |
| 131 |
< |
None}; |
| 95 |
> |
GLX_DEPTH_SIZE,15, None}; |
| 96 |
|
char *gv; |
| 97 |
|
double gamval = GAMMA; |
| 98 |
|
XSetWindowAttributes ourwinattr; |
| 99 |
|
XWMHints ourxwmhints; |
| 100 |
|
XSizeHints oursizhints; |
| 101 |
+ |
/* set quadtree globals */ |
| 102 |
+ |
qtMinNodesiz = 3; |
| 103 |
|
/* open display server */ |
| 104 |
|
ourdisplay = XOpenDisplay(NULL); |
| 105 |
|
if (ourdisplay == NULL) |
| 147 |
|
glDepthFunc(GL_LEQUAL); |
| 148 |
|
glShadeModel(GL_FLAT); |
| 149 |
|
glDisable(GL_DITHER); |
| 150 |
+ |
glDisable(GL_CULL_FACE); |
| 151 |
+ |
glMatrixMode(GL_PROJECTION); |
| 152 |
+ |
glOrtho(0., 1., 0., 1., -.01, 1.01); |
| 153 |
+ |
glTranslated(0., 0., -1.01); |
| 154 |
|
/* figure out sensible view */ |
| 155 |
|
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
| 156 |
|
DisplayWidth(ourdisplay, ourscreen); |
| 162 |
|
XMapWindow(ourdisplay, gwind); |
| 163 |
|
dev_input(); /* sets size and view angles */ |
| 164 |
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 165 |
< |
/* allocate our value list */ |
| 166 |
< |
if (!AllocValues(DisplayWidth(ourdisplay,ourscreen) * |
| 167 |
< |
DisplayHeight(ourdisplay,ourscreen) / VALUA)) |
| 165 |
> |
/* allocate our leaf pile */ |
| 166 |
> |
if (!qtAllocLeaves(2 * DisplayWidth(ourdisplay,ourscreen) * |
| 167 |
> |
DisplayHeight(ourdisplay,ourscreen) / |
| 168 |
> |
(qtMinNodesiz*qtMinNodesiz))) |
| 169 |
|
error(SYSTEM, "insufficient memory for value storage"); |
| 170 |
|
odev.name = id; |
| 171 |
|
odev.ifd = ConnectionNumber(ourdisplay); |
| 172 |
+ |
/* initialize cone array */ |
| 173 |
+ |
initcones(); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 182 |
|
gwind = 0; |
| 183 |
|
XCloseDisplay(ourdisplay); |
| 184 |
|
ourdisplay = NULL; |
| 185 |
+ |
qtFreeLeaves(); |
| 186 |
|
tmDone(NULL); |
| 187 |
< |
FreeValues(); |
| 187 |
> |
freecones(); |
| 188 |
|
odev.v.type = 0; |
| 189 |
|
odev.hres = odev.vres = 0; |
| 190 |
|
odev.ifd = -1; |
| 195 |
|
dev_view(nv) /* assign new driver view */ |
| 196 |
|
register VIEW *nv; |
| 197 |
|
{ |
| 198 |
< |
if (nv->type != VT_PER || /* check view legality */ |
| 199 |
< |
nv->horiz > 120. || nv->vert > 120.) { |
| 198 |
> |
if (nv->type == VT_PAR || /* check view legality */ |
| 199 |
> |
nv->horiz > 160. || nv->vert > 160.) { |
| 200 |
|
error(COMMAND, "illegal view type/angle"); |
| 201 |
< |
nv->type = VT_PER; |
| 201 |
> |
nv->type = odev.v.type; |
| 202 |
|
nv->horiz = odev.v.horiz; |
| 203 |
|
nv->vert = odev.v.vert; |
| 204 |
|
return(0); |
| 205 |
|
} |
| 206 |
+ |
if (nv->vfore > FTINY) { |
| 207 |
+ |
error(COMMAND, "cannot handle fore clipping"); |
| 208 |
+ |
nv->vfore = 0.; |
| 209 |
+ |
return(0); |
| 210 |
+ |
} |
| 211 |
|
if (nv != &odev.v) { |
| 212 |
|
if (!FEQ(nv->horiz,odev.v.horiz) || /* resize window? */ |
| 213 |
|
!FEQ(nv->vert,odev.v.vert)) { |
| 232 |
|
dev_input(); /* get resize event */ |
| 233 |
|
} |
| 234 |
|
copystruct(&odev.v, nv); |
| 256 |
– |
setGLview(); |
| 257 |
– |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 258 |
– |
redraw(); |
| 235 |
|
} |
| 236 |
+ |
if (nxtzmax > FTINY) { |
| 237 |
+ |
curzmax = nxtzmax; |
| 238 |
+ |
nxtzmax = 0.; |
| 239 |
+ |
} |
| 240 |
+ |
glClear(GL_DEPTH_BUFFER_BIT); |
| 241 |
+ |
qtReplant(); |
| 242 |
|
return(1); |
| 243 |
|
} |
| 244 |
|
|
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
|
| 260 |
< |
dev_value(c, p, v) /* add a pixel value to our list */ |
| 261 |
< |
COLR c; |
| 280 |
< |
FVECT p, v; |
| 260 |
> |
int |
| 261 |
> |
dev_flush() /* flush output */ |
| 262 |
|
{ |
| 263 |
< |
register int li; |
| 264 |
< |
|
| 265 |
< |
li = rV.tl++; |
| 285 |
< |
if (rV.tl >= rV.nl) /* get next leaf in ring */ |
| 286 |
< |
rV.tl = 0; |
| 287 |
< |
if (rV.tl == rV.bl) /* need to shake some free */ |
| 288 |
< |
Compost(FREEPCT); |
| 289 |
< |
VCOPY(rV.wp[li], p); |
| 290 |
< |
rV.wd[li] = encodedir(v); |
| 291 |
< |
tmCvColrs(&rV.brt[li], rV.chr[li], c, 1); |
| 263 |
> |
qtUpdate(); |
| 264 |
> |
glFlush(); |
| 265 |
> |
return(XPending(ourdisplay)); |
| 266 |
|
} |
| 267 |
|
|
| 268 |
|
|
| 269 |
< |
int |
| 270 |
< |
dev_flush() /* flush output */ |
| 269 |
> |
dev_cone(rgb, ip, rad) /* render a cone in view coordinates */ |
| 270 |
> |
BYTE rgb[3]; |
| 271 |
> |
FVECT ip; |
| 272 |
> |
double rad; |
| 273 |
|
{ |
| 274 |
< |
if (mapped) { |
| 275 |
< |
TMapValues(0); |
| 276 |
< |
while (rV.drl != rV.tl) { |
| 277 |
< |
drawvalue(rV.drl); |
| 278 |
< |
if (++rV.drl >= rV.nl) |
| 279 |
< |
rV.drl = 0; |
| 280 |
< |
} |
| 281 |
< |
glFlush(); |
| 274 |
> |
register int ci, j; |
| 275 |
> |
double apexh, basez; |
| 276 |
> |
/* compute apex height (0. to 1.) */ |
| 277 |
> |
if (ip[2] > 1e6) |
| 278 |
> |
apexh = 1. - 1./DEPTHFACT; |
| 279 |
> |
else { |
| 280 |
> |
if (ip[2] > nxtzmax) |
| 281 |
> |
nxtzmax = ip[2]; |
| 282 |
> |
if (ip[2] >= curzmax) |
| 283 |
> |
apexh = 1. - 1./DEPTHFACT; |
| 284 |
> |
else |
| 285 |
> |
apexh = 1. - ip[2]/(curzmax*DEPTHFACT); |
| 286 |
|
} |
| 287 |
< |
return(XPending(ourdisplay)); |
| 287 |
> |
/* find closest cone match */ |
| 288 |
> |
for (ci = 0; ci < MAXCONE-1; ci++) |
| 289 |
> |
if (cone[ci].rad >= rad) |
| 290 |
> |
break; |
| 291 |
> |
/* draw it */ |
| 292 |
> |
glColor3ub(rgb[0], rgb[1], rgb[2]); |
| 293 |
> |
glBegin(GL_TRIANGLE_FAN); |
| 294 |
> |
glVertex3d(ip[0], ip[1], apexh); /* start with apex */ |
| 295 |
> |
basez = apexh*cone[ci].va[0][2]; /* base z's all the same */ |
| 296 |
> |
for (j = 0; j < cone[ci].nverts; j++) /* draw each face */ |
| 297 |
> |
glVertex3d(ip[0]+cone[ci].va[j][0], ip[1]+cone[ci].va[j][1], |
| 298 |
> |
basez); |
| 299 |
> |
/* connect last to first */ |
| 300 |
> |
glVertex3d(ip[0]+cone[ci].va[0][0], ip[1]+cone[ci].va[0][1], basez); |
| 301 |
> |
glEnd(); /* all done */ |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
static |
| 325 |
< |
setGLview() /* set our GL view */ |
| 325 |
> |
initcones() /* initialize cone vertices */ |
| 326 |
|
{ |
| 333 |
– |
double xmin, xmax, ymin, ymax, zmin, zmax; |
| 334 |
– |
double d, cx, sx, crad; |
| 335 |
– |
FVECT vx, vy; |
| 327 |
|
register int i, j; |
| 328 |
< |
/* compute view frustum */ |
| 338 |
< |
if (normalize(odev.v.vdir) == 0.0) |
| 339 |
< |
return; |
| 340 |
< |
if (mindepth < maxdepth) { |
| 341 |
< |
zmin = 0.25*mindepth; |
| 342 |
< |
zmax = 4.0*(1.+CONEH)*maxdepth; |
| 343 |
< |
} else { |
| 344 |
< |
zmin = 0.01; |
| 345 |
< |
zmax = 1000.; |
| 346 |
< |
} |
| 347 |
< |
if (odev.v.vfore > FTINY) |
| 348 |
< |
zmin = odev.v.vfore; |
| 349 |
< |
if (odev.v.vaft > FTINY) |
| 350 |
< |
zmax = odev.v.vaft; |
| 351 |
< |
xmax = zmin * tan(PI/180./2. * odev.v.horiz); |
| 352 |
< |
xmin = -xmax; |
| 353 |
< |
d = odev.v.hoff * (xmax - xmin); |
| 354 |
< |
xmin += d; xmax += d; |
| 355 |
< |
ymax = zmin * tan(PI/180./2. * odev.v.vert); |
| 356 |
< |
ymin = -ymax; |
| 357 |
< |
d = odev.v.voff * (ymax - ymin); |
| 358 |
< |
ymin += d; ymax += d; |
| 359 |
< |
/* set view matrix */ |
| 360 |
< |
glMatrixMode(GL_PROJECTION); |
| 361 |
< |
glLoadIdentity(); |
| 362 |
< |
glFrustum(xmin, xmax, ymin, ymax, zmin, zmax); |
| 363 |
< |
gluLookAt(odev.v.vp[0], odev.v.vp[1], odev.v.vp[2], |
| 364 |
< |
odev.v.vp[0] + odev.v.vdir[0], |
| 365 |
< |
odev.v.vp[1] + odev.v.vdir[1], |
| 366 |
< |
odev.v.vp[2] + odev.v.vdir[2], |
| 367 |
< |
odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]); |
| 368 |
< |
/* set viewport */ |
| 369 |
< |
glViewport(0, 0, odev.hres, odev.vres); |
| 370 |
< |
/* initialize cone for Vornoi polys */ |
| 371 |
< |
coneh = CONEH*(zmax - zmin); |
| 372 |
< |
crad = 0.5 * CONEW * 0.5*(xmax-xmin + ymax-ymin) * (zmin+coneh)/zmin; |
| 373 |
< |
vy[0] = vy[1] = vy[2] = 0.; |
| 374 |
< |
for (i = 0; i < 3; i++) |
| 375 |
< |
if (odev.v.vdir[i] < 0.6 && odev.v.vdir[i] > -0.6) |
| 376 |
< |
break; |
| 377 |
< |
vy[i] = 1.; |
| 378 |
< |
fcross(vx, vy, odev.v.vdir); |
| 379 |
< |
normalize(vx); |
| 380 |
< |
fcross(vy, odev.v.vdir, vx); |
| 381 |
< |
for (j = 0, d = 0.; j < NCONEV; j++, d += 2.*PI/NCONEV) { |
| 382 |
< |
cx = crad*cos(d); sx = crad*sin(d); |
| 383 |
< |
for (i = 0; i < 3; i++) |
| 384 |
< |
conev[j][i] = coneh*odev.v.vdir[i] + |
| 385 |
< |
cx*vx[i] + sx*vy[i]; |
| 386 |
< |
} |
| 387 |
< |
} |
| 328 |
> |
double minrad, d; |
| 329 |
|
|
| 330 |
< |
|
| 331 |
< |
#define SUCCSTEP 8 /* skip step when successful */ |
| 332 |
< |
#define MAXSTEP 64 |
| 333 |
< |
|
| 334 |
< |
static |
| 335 |
< |
drawvalue(li) /* draw a pixel value as a cone */ |
| 336 |
< |
register int li; |
| 337 |
< |
{ |
| 338 |
< |
static int skipstep = 1; |
| 339 |
< |
static FVECT disp; |
| 340 |
< |
FVECT apex; |
| 341 |
< |
double d, dorg, dnew, h, v; |
| 342 |
< |
register int i; |
| 343 |
< |
/* check for quicker update */ |
| 344 |
< |
if (quicken) { |
| 345 |
< |
if (li % skipstep) |
| 405 |
< |
return; |
| 406 |
< |
if (skipstep < MAXSTEP) |
| 407 |
< |
skipstep++; |
| 408 |
< |
} |
| 409 |
< |
/* compute cone coordinates */ |
| 410 |
< |
disp[0] = rV.wp[li][0] - odev.v.vp[0]; |
| 411 |
< |
disp[1] = rV.wp[li][1] - odev.v.vp[1]; |
| 412 |
< |
disp[2] = rV.wp[li][2] - odev.v.vp[2]; |
| 413 |
< |
dorg = DOT(disp,odev.v.vdir); |
| 414 |
< |
if (dorg <= odev.v.vfore) |
| 415 |
< |
return; /* clipped too near */ |
| 416 |
< |
if (odev.v.vaft > FTINY && dorg > odev.v.vaft) |
| 417 |
< |
return; /* clipped too far */ |
| 418 |
< |
if (dorg > 1e5) { /* background pixel */ |
| 419 |
< |
dnew = maxdepth; |
| 420 |
< |
d = dnew/dorg; |
| 421 |
< |
dorg = maxdepth; |
| 422 |
< |
} else { /* foreground pixel, compute penalty */ |
| 423 |
< |
normalize(disp); |
| 424 |
< |
d = dnew = dorg + coneh*fdir2diff(rV.wd[li],disp)*DIRPEN; |
| 425 |
< |
} |
| 426 |
< |
/* compute adjusted apex position */ |
| 427 |
< |
disp[0] *= d; disp[1] *= d; disp[2] *= d; |
| 428 |
< |
apex[0] = odev.v.vp[0] + disp[0]; |
| 429 |
< |
apex[1] = odev.v.vp[1] + disp[1]; |
| 430 |
< |
apex[2] = odev.v.vp[2] + disp[2]; |
| 431 |
< |
/* compute view position and base offset */ |
| 432 |
< |
h = DOT(disp,odev.v.hvec)/(dnew*odev.v.hn2); |
| 433 |
< |
v = DOT(disp,odev.v.vvec)/(dnew*odev.v.vn2); |
| 434 |
< |
if (fabs(h - odev.v.hoff) > 0.5 || fabs(v - odev.v.voff) > 0.5) |
| 435 |
< |
return; /* clipped off screen */ |
| 436 |
< |
if (dorg < mindepth) |
| 437 |
< |
mindepth = dorg; |
| 438 |
< |
if (dorg > maxdepth) |
| 439 |
< |
maxdepth = dorg; |
| 440 |
< |
for (i = 0; i < 3; i++) |
| 441 |
< |
disp[i] = apex[i] + coneh*(h*odev.v.hvec[i] + v*odev.v.vvec[i]); |
| 442 |
< |
/* draw cone (pyramid approx.) */ |
| 443 |
< |
glColor4ub(rV.rgb[li][0], rV.rgb[li][1], rV.rgb[li][2], rV.alpha[li]); |
| 444 |
< |
glBegin(GL_TRIANGLE_FAN); |
| 445 |
< |
glVertex3f(apex[0], apex[1], apex[2]); |
| 446 |
< |
for (i = 0; i < NCONEV; i++) |
| 447 |
< |
glVertex3d(conev[i][0] + disp[0], conev[i][1] + disp[1], |
| 448 |
< |
conev[i][2] + disp[2]); |
| 449 |
< |
/* connect last face to first */ |
| 450 |
< |
glVertex3d(conev[0][0] + disp[0], conev[0][1] + disp[1], |
| 451 |
< |
conev[0][2] + disp[2]); |
| 452 |
< |
glEnd(); /* done */ |
| 453 |
< |
skipstep = SUCCSTEP; |
| 454 |
< |
} |
| 455 |
< |
|
| 456 |
< |
#undef SUCCSTEP |
| 457 |
< |
#undef MAXSTEP |
| 458 |
< |
|
| 459 |
< |
|
| 460 |
< |
#define LEAFSIZ (3*sizeof(float)+sizeof(int4)+\ |
| 461 |
< |
sizeof(TMbright)+7*sizeof(BYTE)) |
| 462 |
< |
|
| 463 |
< |
static |
| 464 |
< |
AllocValues(n) /* allocate space for n values */ |
| 465 |
< |
register int n; |
| 466 |
< |
{ |
| 467 |
< |
unsigned nbytes; |
| 468 |
< |
register unsigned i; |
| 469 |
< |
|
| 470 |
< |
if (n <= 0) |
| 471 |
< |
return(0); |
| 472 |
< |
if (rV.nl >= n) |
| 473 |
< |
return(rV.nl); |
| 474 |
< |
else if (rV.nl > 0) |
| 475 |
< |
free(rV.base); |
| 476 |
< |
/* round space up to nearest power of 2 */ |
| 477 |
< |
nbytes = n*LEAFSIZ + 8; |
| 478 |
< |
for (i = 1024; nbytes > i; i <<= 1) |
| 479 |
< |
; |
| 480 |
< |
n = (i - 8) / LEAFSIZ; /* should we make sure n is even? */ |
| 481 |
< |
rV.base = (char *)malloc(n*LEAFSIZ); |
| 482 |
< |
if (rV.base == NULL) |
| 483 |
< |
return(0); |
| 484 |
< |
/* assign larger alignment types earlier */ |
| 485 |
< |
rV.wp = (float (*)[3])rV.base; |
| 486 |
< |
rV.wd = (int4 *)(rV.wp + n); |
| 487 |
< |
rV.brt = (TMbright *)(rV.wd + n); |
| 488 |
< |
rV.chr = (BYTE (*)[3])(rV.brt + n); |
| 489 |
< |
rV.rgb = (BYTE (*)[3])(rV.chr + n); |
| 490 |
< |
rV.alpha = (BYTE *)(rV.rgb + n); |
| 491 |
< |
rV.nl = n; |
| 492 |
< |
rV.drl = rV.tml = rV.bl = rV.tl = 0; |
| 493 |
< |
return(n); |
| 494 |
< |
} |
| 495 |
< |
|
| 496 |
< |
#undef LEAFSIZ |
| 497 |
< |
|
| 498 |
< |
|
| 499 |
< |
static |
| 500 |
< |
FreeValues() /* free our allocated values */ |
| 501 |
< |
{ |
| 502 |
< |
if (rV.nl <= 0) |
| 503 |
< |
return; |
| 504 |
< |
free(rV.base); |
| 505 |
< |
rV.base = NULL; |
| 506 |
< |
rV.nl = 0; |
| 507 |
< |
} |
| 508 |
< |
|
| 509 |
< |
|
| 510 |
< |
static |
| 511 |
< |
clralphas() /* prepare for new alpha values */ |
| 512 |
< |
{ |
| 513 |
< |
if (!vmaplen) |
| 514 |
< |
return; |
| 515 |
< |
free((char *)valmap); |
| 516 |
< |
valmap = NULL; |
| 517 |
< |
vmaplen = 0; |
| 518 |
< |
} |
| 519 |
< |
|
| 520 |
< |
|
| 521 |
< |
static int |
| 522 |
< |
valcmp(v1p, v2p) /* compare two pixel values */ |
| 523 |
< |
int *v1p, *v2p; |
| 524 |
< |
{ |
| 525 |
< |
register int v1 = *v1p, v2 = *v2p; |
| 526 |
< |
register int c; |
| 527 |
< |
|
| 528 |
< |
if ((c = rV.rgb[v1][0] - rV.rgb[v2][0])) return(c); |
| 529 |
< |
if ((c = rV.rgb[v1][1] - rV.rgb[v2][1])) return(c); |
| 530 |
< |
if ((c = rV.rgb[v1][2] - rV.rgb[v2][2])) return(c); |
| 531 |
< |
return(rV.alpha[v1] - rV.alpha[v2]); |
| 532 |
< |
} |
| 533 |
< |
|
| 534 |
< |
|
| 535 |
< |
static |
| 536 |
< |
mergalphas(adest, al1, n1, al2, n2) /* merge two sorted alpha lists */ |
| 537 |
< |
register int *adest, *al1, *al2; |
| 538 |
< |
int n1, n2; |
| 539 |
< |
{ |
| 540 |
< |
register int cmp; |
| 541 |
< |
|
| 542 |
< |
while (n1 | n2) { |
| 543 |
< |
if (!n1) cmp = 1; |
| 544 |
< |
else if (!n2) cmp = -1; |
| 545 |
< |
else cmp = valcmp(al1, al2); |
| 546 |
< |
if (cmp > 0) { |
| 547 |
< |
*adest++ = *al2++; |
| 548 |
< |
n2--; |
| 549 |
< |
} else { |
| 550 |
< |
*adest++ = *al1++; |
| 551 |
< |
n1--; |
| 330 |
> |
if (cone[0].nverts) |
| 331 |
> |
freecones(); |
| 332 |
> |
minrad = 2.*qtMinNodesiz/(double)(DisplayWidth(ourdisplay,ourscreen) + |
| 333 |
> |
DisplayHeight(ourdisplay,ourscreen)); |
| 334 |
> |
for (i = 0; i < MAXCONE; i++) { |
| 335 |
> |
d = (double)i/(MAXCONE-1); d *= d; /* x^2 distribution */ |
| 336 |
> |
cone[i].rad = minrad + (1.-minrad)*d; |
| 337 |
> |
cone[i].nverts = MINVERT + (MAXVERT-MINVERT)*d; |
| 338 |
> |
cone[i].va = (FVECT *)malloc(cone[i].nverts*sizeof(FVECT)); |
| 339 |
> |
if (cone[i].va == NULL) |
| 340 |
> |
error(SYSTEM, "out of memory in initcones"); |
| 341 |
> |
for (j = cone[i].nverts; j--; ) { |
| 342 |
> |
d = 2.*PI * (j+.5) / (cone[i].nverts); |
| 343 |
> |
cone[i].va[j][0] = cos(d) * cone[i].rad; |
| 344 |
> |
cone[i].va[j][1] = sin(d) * cone[i].rad; |
| 345 |
> |
cone[i].va[j][2] = 1. - cone[i].rad; |
| 346 |
|
} |
| 347 |
|
} |
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
|
| 351 |
|
static |
| 352 |
< |
setalphas(vbeg, nvals) /* add values to our map and set alphas */ |
| 559 |
< |
int vbeg, nvals; |
| 352 |
> |
freecones() /* free cone vertices */ |
| 353 |
|
{ |
| 354 |
< |
register int *newmap; |
| 562 |
< |
short ccmp[3], lastalpha; |
| 563 |
< |
int newmaplen; |
| 354 |
> |
register int i; |
| 355 |
|
|
| 356 |
< |
if (nvals <= 0) |
| 357 |
< |
return; |
| 358 |
< |
newmaplen = vmaplen + nvals; /* allocate new map */ |
| 359 |
< |
newmap = (int *)malloc(newmaplen*sizeof(int)); |
| 360 |
< |
if (newmap == NULL) |
| 570 |
< |
error(SYSTEM, "out of memory in setalphas"); |
| 571 |
< |
while (nvals--) { /* add new values to end */ |
| 572 |
< |
rV.alpha[vbeg] = 255; |
| 573 |
< |
newmap[vmaplen+nvals] = vbeg++; |
| 574 |
< |
} |
| 575 |
< |
if (nvals >= 3*vmaplen) { /* resort the combined array */ |
| 576 |
< |
while (vmaplen--) |
| 577 |
< |
newmap[vmaplen] = valmap[vmaplen]; |
| 578 |
< |
qsort((char *)newmap, newmaplen, sizeof(int), valcmp); |
| 579 |
< |
} else { /* perform merge sort */ |
| 580 |
< |
qsort((char *)(newmap+vmaplen), newmaplen-vmaplen, |
| 581 |
< |
sizeof(int), valcmp); |
| 582 |
< |
mergalphas(newmap, valmap, vmaplen, |
| 583 |
< |
newmap+vmaplen, newmaplen-vmaplen); |
| 584 |
< |
} |
| 585 |
< |
if (valmap != NULL) /* free old map and assign new one */ |
| 586 |
< |
free((char *)valmap); |
| 587 |
< |
valmap = newmap; |
| 588 |
< |
vmaplen = newmaplen; |
| 589 |
< |
lastalpha = 0; /* set new alpha values */ |
| 590 |
< |
ccmp[0] = ccmp[1] = ccmp[2] = 256; |
| 591 |
< |
while (newmaplen--) |
| 592 |
< |
if (rV.rgb[*newmap][0] == ccmp[0] && |
| 593 |
< |
rV.rgb[*newmap][1] == ccmp[1] && |
| 594 |
< |
rV.rgb[*newmap][2] == ccmp[2]) { |
| 595 |
< |
if (lastalpha >= 255) |
| 596 |
< |
newmap++; |
| 597 |
< |
else if (rV.alpha[*newmap] < 255) |
| 598 |
< |
lastalpha = rV.alpha[*newmap++]; |
| 599 |
< |
else |
| 600 |
< |
rV.alpha[*newmap++] = ++lastalpha; |
| 601 |
< |
} else { |
| 602 |
< |
ccmp[0] = rV.rgb[*newmap][0]; |
| 603 |
< |
ccmp[1] = rV.rgb[*newmap][1]; |
| 604 |
< |
ccmp[2] = rV.rgb[*newmap][2]; |
| 605 |
< |
if (rV.alpha[*newmap] < 255) |
| 606 |
< |
lastalpha = rV.alpha[*newmap++]; |
| 607 |
< |
else |
| 608 |
< |
rV.alpha[*newmap++] = lastalpha = 1; |
| 356 |
> |
for (i = MAXCONE; i--; ) |
| 357 |
> |
if (cone[i].nverts) { |
| 358 |
> |
free((char *)cone[i].va); |
| 359 |
> |
cone[i].va = NULL; |
| 360 |
> |
cone[i].nverts = 0; |
| 361 |
|
} |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
|
| 365 |
|
static |
| 614 |
– |
TMapValues(redo) /* map our values to RGB */ |
| 615 |
– |
int redo; |
| 616 |
– |
{ |
| 617 |
– |
int aorg, alen, borg, blen; |
| 618 |
– |
/* recompute mapping? */ |
| 619 |
– |
if (redo) |
| 620 |
– |
rV.tml = rV.bl; |
| 621 |
– |
/* already done? */ |
| 622 |
– |
if (rV.tml == rV.tl) |
| 623 |
– |
return(1); |
| 624 |
– |
/* compute segments */ |
| 625 |
– |
aorg = rV.tml; |
| 626 |
– |
if (rV.tl >= aorg) { |
| 627 |
– |
alen = rV.tl - aorg; |
| 628 |
– |
blen = 0; |
| 629 |
– |
} else { |
| 630 |
– |
alen = rV.nl - aorg; |
| 631 |
– |
borg = 0; |
| 632 |
– |
blen = rV.tl; |
| 633 |
– |
} |
| 634 |
– |
/* (re)compute tone mapping? */ |
| 635 |
– |
if (rV.tml == rV.bl) { |
| 636 |
– |
tmClearHisto(); |
| 637 |
– |
tmAddHisto(rV.brt+aorg, alen, 1); |
| 638 |
– |
if (blen > 0) |
| 639 |
– |
tmAddHisto(rV.brt+borg, blen, 1); |
| 640 |
– |
if (tmComputeMapping(0., 0., 0.) != TM_E_OK) |
| 641 |
– |
return(0); |
| 642 |
– |
clralphas(); /* restart value list */ |
| 643 |
– |
rV.drl = rV.bl; /* need to redraw */ |
| 644 |
– |
} |
| 645 |
– |
if (tmMapPixels(rV.rgb+aorg, rV.brt+aorg, |
| 646 |
– |
rV.chr+aorg, alen) != TM_E_OK) |
| 647 |
– |
return(0); |
| 648 |
– |
if (blen > 0) |
| 649 |
– |
tmMapPixels(rV.rgb+borg, rV.brt+borg, |
| 650 |
– |
rV.chr+borg, blen); |
| 651 |
– |
setalphas(aorg, alen); /* compute add'l alpha values */ |
| 652 |
– |
if (blen > 0) |
| 653 |
– |
setalphas(borg, blen); |
| 654 |
– |
rV.tml = rV.tl; /* we're all up to date */ |
| 655 |
– |
return(1); |
| 656 |
– |
} |
| 657 |
– |
|
| 658 |
– |
|
| 659 |
– |
static int |
| 660 |
– |
Compost(pct) /* free up some values */ |
| 661 |
– |
int pct; |
| 662 |
– |
{ |
| 663 |
– |
int nused, nclear, nmapped, ndrawn; |
| 664 |
– |
/* figure out how many values to clear */ |
| 665 |
– |
nclear = rV.nl * pct / 100; |
| 666 |
– |
nused = rV.tl - rV.bl; |
| 667 |
– |
if (nused <= 0) nused += rV.nl; |
| 668 |
– |
nclear -= rV.nl - nused; |
| 669 |
– |
if (nclear <= 0) |
| 670 |
– |
return(0); |
| 671 |
– |
if (nclear >= nused) { /* clear them all? */ |
| 672 |
– |
rV.drl = rV.tml = rV.bl = rV.tl = 0; |
| 673 |
– |
return(nused); |
| 674 |
– |
} |
| 675 |
– |
/* else clear values from bottom */ |
| 676 |
– |
ndrawn = rV.drl - rV.bl; |
| 677 |
– |
if (ndrawn < 0) ndrawn += rV.nl; |
| 678 |
– |
nmapped = rV.tml - rV.bl; |
| 679 |
– |
if (nmapped < 0) nmapped += rV.nl; |
| 680 |
– |
rV.bl += nclear; |
| 681 |
– |
if (rV.bl >= rV.nl) rV.bl -= rV.nl; |
| 682 |
– |
if (ndrawn < nclear) rV.drl = rV.bl; |
| 683 |
– |
if (nmapped < nclear) rV.tml = rV.bl; |
| 684 |
– |
return(nclear); |
| 685 |
– |
} |
| 686 |
– |
|
| 687 |
– |
|
| 688 |
– |
static |
| 366 |
|
getevent() /* get next event */ |
| 367 |
|
{ |
| 368 |
|
XNextEvent(ourdisplay, levptr(XEvent)); |
| 402 |
|
draw_grids() /* draw holodeck section grids */ |
| 403 |
|
{ |
| 404 |
|
static BYTE gridrgba[4] = {0x0, 0xff, 0xff, 0x00}; |
| 405 |
< |
|
| 406 |
< |
if (!mapped) |
| 405 |
> |
double xmin, xmax, ymin, ymax, zmin, zmax; |
| 406 |
> |
double d, cx, sx, crad; |
| 407 |
> |
FVECT vx, vy; |
| 408 |
> |
register int i, j; |
| 409 |
> |
/* can we even do it? */ |
| 410 |
> |
if (!mapped || odev.v.type != VT_PER) |
| 411 |
|
return; |
| 412 |
+ |
/* compute view frustum */ |
| 413 |
+ |
if (normalize(odev.v.vdir) == 0.0) |
| 414 |
+ |
return; |
| 415 |
+ |
zmin = 0.01; |
| 416 |
+ |
zmax = 10000.; |
| 417 |
+ |
if (odev.v.vfore > FTINY) |
| 418 |
+ |
zmin = odev.v.vfore; |
| 419 |
+ |
if (odev.v.vaft > FTINY) |
| 420 |
+ |
zmax = odev.v.vaft; |
| 421 |
+ |
xmax = zmin * tan(PI/180./2. * odev.v.horiz); |
| 422 |
+ |
xmin = -xmax; |
| 423 |
+ |
d = odev.v.hoff * (xmax - xmin); |
| 424 |
+ |
xmin += d; xmax += d; |
| 425 |
+ |
ymax = zmin * tan(PI/180./2. * odev.v.vert); |
| 426 |
+ |
ymin = -ymax; |
| 427 |
+ |
d = odev.v.voff * (ymax - ymin); |
| 428 |
+ |
ymin += d; ymax += d; |
| 429 |
+ |
/* set view matrix */ |
| 430 |
+ |
glMatrixMode(GL_PROJECTION); |
| 431 |
+ |
glPushMatrix(); |
| 432 |
+ |
glLoadIdentity(); |
| 433 |
+ |
glFrustum(xmin, xmax, ymin, ymax, zmin, zmax); |
| 434 |
+ |
gluLookAt(odev.v.vp[0], odev.v.vp[1], odev.v.vp[2], |
| 435 |
+ |
odev.v.vp[0] + odev.v.vdir[0], |
| 436 |
+ |
odev.v.vp[1] + odev.v.vdir[1], |
| 437 |
+ |
odev.v.vp[2] + odev.v.vdir[2], |
| 438 |
+ |
odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]); |
| 439 |
+ |
glDisable(GL_DEPTH_TEST); /* write no depth values */ |
| 440 |
|
glColor4ub(gridrgba[0], gridrgba[1], gridrgba[2], gridrgba[3]); |
| 441 |
< |
/* draw each grid line */ |
| 733 |
< |
glBegin(GL_LINES); |
| 441 |
> |
glBegin(GL_LINES); /* draw each grid line */ |
| 442 |
|
gridlines(draw3dline); |
| 443 |
|
glEnd(); |
| 444 |
+ |
glEnable(GL_DEPTH_TEST); /* restore rendering params */ |
| 445 |
+ |
glPopMatrix(); |
| 446 |
|
} |
| 447 |
|
|
| 448 |
|
|
| 739 |
– |
static int |
| 740 |
– |
IndexValue(rgba) /* locate a pixel by it's framebuffer value */ |
| 741 |
– |
register BYTE rgba[4]; |
| 742 |
– |
{ |
| 743 |
– |
register int *vp; |
| 744 |
– |
/* check legality */ |
| 745 |
– |
if (rgba[3] == 0 || rgba[3] == 255) |
| 746 |
– |
return(-1); |
| 747 |
– |
/* borrow a value slot */ |
| 748 |
– |
rV.rgb[rV.tl][0] = rgba[0]; |
| 749 |
– |
rV.rgb[rV.tl][1] = rgba[1]; |
| 750 |
– |
rV.rgb[rV.tl][2] = rgba[2]; |
| 751 |
– |
rV.alpha[rV.tl] = rgba[3]; |
| 752 |
– |
/* find it */ |
| 753 |
– |
vp = (int *)bsearch((char *)&rV.tl, (char *)valmap, vmaplen, |
| 754 |
– |
sizeof(int), valcmp); |
| 755 |
– |
if (vp == NULL) |
| 756 |
– |
return(-1); |
| 757 |
– |
return(*vp); |
| 758 |
– |
} |
| 759 |
– |
|
| 760 |
– |
|
| 761 |
– |
static int |
| 762 |
– |
FindValue(dx, dy) /* find a value on the display */ |
| 763 |
– |
int dx, dy; |
| 764 |
– |
{ |
| 765 |
– |
BYTE rgba[4]; |
| 766 |
– |
|
| 767 |
– |
if (dx < 0 || dy < 0 || dx >= odev.hres || dy >= odev.vres) |
| 768 |
– |
return(-1); |
| 769 |
– |
glReadPixels(dx, dy, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, rgba); |
| 770 |
– |
return(IndexValue(rgba)); |
| 771 |
– |
} |
| 772 |
– |
|
| 773 |
– |
|
| 449 |
|
static |
| 450 |
|
moveview(dx, dy, mov, orb) /* move our view */ |
| 451 |
|
int dx, dy, mov, orb; |
| 458 |
|
copystruct(&nv, &odev.v); |
| 459 |
|
/* change view direction */ |
| 460 |
|
if (mov | orb) { |
| 461 |
< |
if ((li = FindValue(dx, dy)) < 0) |
| 461 |
> |
if ((li = qtFindLeaf(dx, dy)) < 0) |
| 462 |
|
return(0); /* not on window */ |
| 463 |
< |
VSUM(odir, rV.wp[li], nv.vp, -1.); |
| 463 |
> |
VSUM(odir, qtL.wp[li], nv.vp, -1.); |
| 464 |
|
} else { |
| 465 |
|
if (viewray(nv.vp, nv.vdir, &odev.v, |
| 466 |
|
(dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) |
| 468 |
|
} |
| 469 |
|
if (orb && mov) { /* orbit left/right */ |
| 470 |
|
spinvector(odir, odir, nv.vup, d=MOVDEG*PI/180.*mov); |
| 471 |
< |
VSUM(nv.vp, rV.wp[li], odir, -1.); |
| 471 |
> |
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
| 472 |
|
spinvector(nv.vdir, nv.vdir, nv.vup, d); |
| 473 |
|
} else if (orb) { /* orbit up/down */ |
| 474 |
|
fcross(v1, odir, nv.vup); |
| 475 |
|
if (normalize(v1) == 0.) |
| 476 |
|
return(0); |
| 477 |
|
spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); |
| 478 |
< |
VSUM(nv.vp, rV.wp[li], odir, -1.); |
| 478 |
> |
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
| 479 |
|
spinvector(nv.vdir, nv.vdir, v1, d); |
| 480 |
|
} else if (mov) { /* move forward/backward */ |
| 481 |
|
d = MOVPCT/100. * mov; |
| 500 |
|
{ |
| 501 |
|
int movdir = MOVDIR(ebut->button); |
| 502 |
|
int movorb = MOVORB(ebut->state); |
| 503 |
+ |
int oldnodesiz = qtMinNodesiz; |
| 504 |
|
Window rootw, childw; |
| 505 |
|
int rootx, rooty, wx, wy; |
| 506 |
|
unsigned int statemask; |
| 507 |
|
|
| 508 |
< |
quicken = 1; /* accelerate update rate */ |
| 508 |
> |
qtMinNodesiz = 24; /* accelerate update rate */ |
| 509 |
|
XNoOp(ourdisplay); |
| 510 |
|
|
| 511 |
|
while (!XCheckMaskEvent(ourdisplay, |
| 519 |
|
sleep(1); |
| 520 |
|
continue; |
| 521 |
|
} |
| 522 |
+ |
glClear(GL_COLOR_BUFFER_BIT); |
| 523 |
+ |
qtUpdate(); |
| 524 |
|
draw_grids(); |
| 525 |
< |
dev_flush(); |
| 525 |
> |
glFlush(); |
| 526 |
|
} |
| 527 |
|
if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */ |
| 528 |
|
movdir = MOVDIR(levptr(XButtonReleasedEvent)->button); |
| 529 |
|
wx = levptr(XButtonReleasedEvent)->x; |
| 530 |
|
wy = levptr(XButtonReleasedEvent)->y; |
| 531 |
|
moveview(wx, odev.vres-1-wy, movdir, movorb); |
| 854 |
– |
} else { |
| 855 |
– |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 856 |
– |
redraw(); |
| 532 |
|
} |
| 858 |
– |
quicken = 0; |
| 533 |
|
dev_flush(); |
| 534 |
+ |
|
| 535 |
+ |
qtMinNodesiz = oldnodesiz; /* restore quadtree resolution */ |
| 536 |
|
} |
| 537 |
|
|
| 538 |
|
|
| 567 |
|
inpresflags |= DFL(DC_RESUME); |
| 568 |
|
return; |
| 569 |
|
case CTRL('R'): /* redraw screen */ |
| 894 |
– |
TMapValues(1); |
| 570 |
|
glClear(GL_DEPTH_BUFFER_BIT); |
| 571 |
< |
redraw(); |
| 571 |
> |
qtRedraw(0, 0, odev.hres, odev.vres); |
| 572 |
|
return; |
| 573 |
|
case CTRL('L'): /* refresh from server */ |
| 574 |
|
if (inpresflags & DFL(DC_REDRAW)) |
| 575 |
|
return; |
| 576 |
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 902 |
– |
glDisable(GL_DEPTH_TEST); |
| 577 |
|
draw_grids(); |
| 904 |
– |
glEnable(GL_DEPTH_TEST); |
| 578 |
|
glFlush(); |
| 579 |
< |
Compost(100); /* get rid of old values */ |
| 579 |
> |
qtCompost(100); /* get rid of old values */ |
| 580 |
|
inpresflags |= DFL(DC_REDRAW); /* resend values from server */ |
| 581 |
|
return; |
| 582 |
|
case 'K': /* kill rtrace process(es) */ |
| 602 |
|
fixwindow(eexp) /* repair damage to window */ |
| 603 |
|
register XExposeEvent *eexp; |
| 604 |
|
{ |
| 605 |
+ |
int xmin, xmax, ymin, ymax; |
| 606 |
+ |
|
| 607 |
|
if (odev.hres == 0 || odev.vres == 0) /* first exposure */ |
| 608 |
|
resizewindow((XConfigureEvent *)eexp); |
| 609 |
< |
if (eexp->width == odev.hres && eexp->height == odev.vres) |
| 610 |
< |
TMapValues(1); |
| 611 |
< |
if (!eexp->count) { |
| 612 |
< |
glClear(GL_DEPTH_BUFFER_BIT); |
| 613 |
< |
redraw(); |
| 614 |
< |
} |
| 609 |
> |
xmin = eexp->x; xmax = eexp->x + eexp->width; |
| 610 |
> |
ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y; |
| 611 |
> |
/* clear portion of depth */ |
| 612 |
> |
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
| 613 |
> |
glDepthFunc(GL_ALWAYS); |
| 614 |
> |
glBegin(GL_POLYGON); |
| 615 |
> |
glVertex3d((double)xmin/odev.hres, (double)ymin/odev.vres, 0.); |
| 616 |
> |
glVertex3d((double)xmax/odev.hres, (double)ymin/odev.vres, 0.); |
| 617 |
> |
glVertex3d((double)xmax/odev.hres, (double)ymax/odev.vres, 0.); |
| 618 |
> |
glVertex3d((double)xmin/odev.hres, (double)ymax/odev.vres, 0.); |
| 619 |
> |
glEnd(); |
| 620 |
> |
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| 621 |
> |
glDepthFunc(GL_LEQUAL); |
| 622 |
> |
qtRedraw(xmin, ymin, xmax, ymax); |
| 623 |
|
} |
| 624 |
|
|
| 625 |
|
|
| 636 |
|
odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres); |
| 637 |
|
odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); |
| 638 |
|
|
| 639 |
< |
setGLview(); |
| 639 |
> |
glViewport(0, 0, odev.hres, odev.vres); |
| 640 |
|
|
| 641 |
|
inpresflags |= DFL(DC_SETVIEW); |
| 642 |
|
} |