| 9 |
|
#include "standard.h" |
| 10 |
|
|
| 11 |
|
#include <GL/glx.h> |
| 12 |
+ |
#include <GL/glu.h> |
| 13 |
|
|
| 14 |
|
#include "rhd_qtree.h" |
| 15 |
< |
|
| 15 |
> |
#include "rhdriver.h" |
| 16 |
> |
#include "rhdisp.h" |
| 17 |
|
#include "x11icon.h" |
| 18 |
|
|
| 19 |
|
#ifndef RAYQLEN |
| 87 |
|
|
| 88 |
|
static int headlocked = 0; /* lock vertical motion */ |
| 89 |
|
|
| 88 |
– |
static int resizewindow(), getevent(), getkey(), moveview(), |
| 89 |
– |
initcones(), freecones(), |
| 90 |
– |
getmove(), fixwindow(), mytmflags(); |
| 90 |
|
|
| 91 |
+ |
static int mytmflags(void); |
| 92 |
+ |
static void initcones(void); |
| 93 |
+ |
static void freecones(void); |
| 94 |
+ |
static void getevent(void); |
| 95 |
+ |
static void draw3dline(FVECT wp[2]); |
| 96 |
+ |
static void draw_grids(void); |
| 97 |
+ |
static int moveview(int dx, int dy, int mov, int orb); |
| 98 |
+ |
static void getmove(XButtonPressedEvent *ebut); |
| 99 |
+ |
static void getkey(XKeyPressedEvent *ekey); |
| 100 |
+ |
static void fixwindow(XExposeEvent *eexp); |
| 101 |
+ |
static void resizewindow(XConfigureEvent *ersz); |
| 102 |
|
|
| 103 |
< |
dev_open(id) /* initialize X11 driver */ |
| 104 |
< |
char *id; |
| 103 |
> |
|
| 104 |
> |
extern void |
| 105 |
> |
dev_open( |
| 106 |
> |
char *id |
| 107 |
> |
) |
| 108 |
|
{ |
| 109 |
|
extern char *getenv(); |
| 110 |
|
static RGBPRIMS myprims = STDPRIMS; |
| 183 |
|
DisplayWidth(ourdisplay, ourscreen); |
| 184 |
|
pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / |
| 185 |
|
DisplayHeight(ourdisplay, ourscreen); |
| 186 |
< |
copystruct(&odev.v, &stdview); |
| 186 |
> |
odev.v = stdview; |
| 187 |
|
odev.v.type = VT_PER; |
| 188 |
|
/* map the window */ |
| 189 |
|
XMapWindow(ourdisplay, gwind); |
| 200 |
|
} |
| 201 |
|
|
| 202 |
|
|
| 203 |
< |
dev_close() /* close our display and free resources */ |
| 203 |
> |
extern void |
| 204 |
> |
dev_close(void) /* close our display and free resources */ |
| 205 |
|
{ |
| 206 |
|
glXMakeCurrent(ourdisplay, None, NULL); |
| 207 |
|
glXDestroyContext(ourdisplay, gctx); |
| 218 |
|
} |
| 219 |
|
|
| 220 |
|
|
| 221 |
< |
dev_clear() /* clear our quadtree */ |
| 221 |
> |
extern void |
| 222 |
> |
dev_clear(void) /* clear our quadtree */ |
| 223 |
|
{ |
| 224 |
|
qtCompost(100); |
| 225 |
|
glClear(GL_DEPTH_BUFFER_BIT); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
|
| 230 |
< |
int |
| 231 |
< |
dev_view(nv) /* assign new driver view */ |
| 232 |
< |
register VIEW *nv; |
| 230 |
> |
extern int |
| 231 |
> |
dev_view( /* assign new driver view */ |
| 232 |
> |
register VIEW *nv |
| 233 |
> |
) |
| 234 |
|
{ |
| 235 |
|
if (nv->type == VT_PAR || /* check view legality */ |
| 236 |
|
nv->horiz > 160. || nv->vert > 160.) { |
| 268 |
|
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
| 269 |
|
dev_input(); /* get resize event */ |
| 270 |
|
} |
| 271 |
< |
copystruct(&odev.v, nv); |
| 271 |
> |
odev.v = *nv; |
| 272 |
|
} |
| 273 |
|
if (nxtzmax > FTINY) { |
| 274 |
|
curzmax = nxtzmax; |
| 280 |
|
} |
| 281 |
|
|
| 282 |
|
|
| 283 |
< |
dev_section(ofn) /* add octree for geometry rendering */ |
| 284 |
< |
char *ofn; |
| 283 |
> |
extern void |
| 284 |
> |
dev_section( /* add octree for geometry rendering */ |
| 285 |
> |
char *ofn |
| 286 |
> |
) |
| 287 |
|
{ |
| 288 |
|
/* unimplemented */ |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
|
| 292 |
< |
dev_auxcom(cmd, args) /* process an auxiliary command */ |
| 293 |
< |
char *cmd, *args; |
| 292 |
> |
extern void |
| 293 |
> |
dev_auxcom( /* process an auxiliary command */ |
| 294 |
> |
char *cmd, |
| 295 |
> |
char *args |
| 296 |
> |
) |
| 297 |
|
{ |
| 298 |
|
sprintf(errmsg, "%s: unknown command", cmd); |
| 299 |
|
error(COMMAND, errmsg); |
| 300 |
|
} |
| 301 |
|
|
| 302 |
|
|
| 303 |
< |
VIEW * |
| 304 |
< |
dev_auxview(n, hvres) /* return nth auxiliary view */ |
| 305 |
< |
int n; |
| 306 |
< |
int hvres[2]; |
| 303 |
> |
extern VIEW * |
| 304 |
> |
dev_auxview( /* return nth auxiliary view */ |
| 305 |
> |
int n, |
| 306 |
> |
int hvres[2] |
| 307 |
> |
) |
| 308 |
|
{ |
| 309 |
|
if (n) |
| 310 |
|
return(NULL); |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
|
| 316 |
< |
int |
| 317 |
< |
dev_input() /* get X11 input */ |
| 316 |
> |
extern int |
| 317 |
> |
dev_input(void) /* get X11 input */ |
| 318 |
|
{ |
| 319 |
|
inpresflags = 0; |
| 320 |
|
|
| 327 |
|
} |
| 328 |
|
|
| 329 |
|
|
| 330 |
< |
int |
| 331 |
< |
dev_flush() /* flush output */ |
| 330 |
> |
extern int |
| 331 |
> |
dev_flush(void) /* flush output */ |
| 332 |
|
{ |
| 333 |
|
qtUpdate(); |
| 334 |
|
glFlush(); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
|
| 340 |
< |
dev_cone(rgb, ip, rad) /* render a cone in view coordinates */ |
| 341 |
< |
BYTE rgb[3]; |
| 342 |
< |
FVECT ip; |
| 343 |
< |
double rad; |
| 340 |
> |
extern void |
| 341 |
> |
dev_cone( /* render a cone in view coordinates */ |
| 342 |
> |
BYTE rgb[3], |
| 343 |
> |
FVECT ip, |
| 344 |
> |
double rad |
| 345 |
> |
) |
| 346 |
|
{ |
| 347 |
|
register int ci, j; |
| 348 |
|
double apexh, basez; |
| 379 |
|
|
| 380 |
|
|
| 381 |
|
static int |
| 382 |
< |
mytmflags() /* figure out tone mapping flags */ |
| 382 |
> |
mytmflags(void) /* figure out tone mapping flags */ |
| 383 |
|
{ |
| 384 |
|
extern char *progname; |
| 385 |
|
register char *cp, *tail; |
| 394 |
|
if (cp-tail == 5 && !strncmp(tail, "glx1h", 5)) |
| 395 |
|
return(TM_F_HUMAN|TM_F_NOSTDERR); |
| 396 |
|
error(USER, "illegal driver name"); |
| 397 |
+ |
return -1; /* pro forma return */ |
| 398 |
|
} |
| 399 |
|
|
| 400 |
|
|
| 401 |
< |
static |
| 402 |
< |
initcones() /* initialize cone vertices */ |
| 401 |
> |
static void |
| 402 |
> |
initcones(void) /* initialize cone vertices */ |
| 403 |
|
{ |
| 404 |
|
register int i, j; |
| 405 |
|
double minrad, d; |
| 425 |
|
} |
| 426 |
|
|
| 427 |
|
|
| 428 |
< |
static |
| 429 |
< |
freecones() /* free cone vertices */ |
| 428 |
> |
static void |
| 429 |
> |
freecones(void) /* free cone vertices */ |
| 430 |
|
{ |
| 431 |
|
register int i; |
| 432 |
|
|
| 439 |
|
} |
| 440 |
|
|
| 441 |
|
|
| 442 |
< |
static |
| 443 |
< |
getevent() /* get next event */ |
| 442 |
> |
static void |
| 443 |
> |
getevent(void) /* get next event */ |
| 444 |
|
{ |
| 445 |
|
XNextEvent(ourdisplay, levptr(XEvent)); |
| 446 |
|
switch (levptr(XEvent)->type) { |
| 466 |
|
} |
| 467 |
|
|
| 468 |
|
|
| 469 |
< |
static |
| 470 |
< |
draw3dline(wp) /* draw 3d line in world coordinates */ |
| 471 |
< |
register FVECT wp[2]; |
| 469 |
> |
static void |
| 470 |
> |
draw3dline( /* draw 3d line in world coordinates */ |
| 471 |
> |
register FVECT wp[2] |
| 472 |
> |
) |
| 473 |
|
{ |
| 474 |
|
glVertex3d(wp[0][0], wp[0][1], wp[0][2]); |
| 475 |
|
glVertex3d(wp[1][0], wp[1][1], wp[1][2]); |
| 476 |
|
} |
| 477 |
|
|
| 478 |
|
|
| 479 |
< |
static |
| 480 |
< |
draw_grids() /* draw holodeck section grids */ |
| 479 |
> |
static void |
| 480 |
> |
draw_grids(void) /* draw holodeck section grids */ |
| 481 |
|
{ |
| 482 |
|
static BYTE gridrgba[4] = {0x0, 0xff, 0xff, 0x00}; |
| 483 |
|
double xmin, xmax, ymin, ymax, zmin, zmax; |
| 484 |
< |
double d, cx, sx, crad; |
| 459 |
< |
FVECT vx, vy; |
| 460 |
< |
register int i, j; |
| 484 |
> |
double d; |
| 485 |
|
/* can we even do it? */ |
| 486 |
|
if (!mapped || odev.v.type != VT_PER) |
| 487 |
|
return; |
| 522 |
|
} |
| 523 |
|
|
| 524 |
|
|
| 525 |
< |
static |
| 526 |
< |
moveview(dx, dy, mov, orb) /* move our view */ |
| 527 |
< |
int dx, dy, mov, orb; |
| 525 |
> |
static int |
| 526 |
> |
moveview( /* move our view */ |
| 527 |
> |
int dx, |
| 528 |
> |
int dy, |
| 529 |
> |
int mov, |
| 530 |
> |
int orb |
| 531 |
> |
) |
| 532 |
|
{ |
| 533 |
|
VIEW nv; |
| 534 |
|
FVECT odir, v1; |
| 535 |
|
double d; |
| 536 |
|
register int li; |
| 537 |
|
/* start with old view */ |
| 538 |
< |
copystruct(&nv, &odev.v); |
| 538 |
> |
nv = odev.v; |
| 539 |
|
/* change view direction */ |
| 540 |
|
if (mov | orb) { |
| 541 |
|
if ((li = qtFindLeaf(dx, dy)) < 0) |
| 574 |
|
} |
| 575 |
|
|
| 576 |
|
|
| 577 |
< |
static |
| 578 |
< |
getmove(ebut) /* get view change */ |
| 579 |
< |
XButtonPressedEvent *ebut; |
| 577 |
> |
static void |
| 578 |
> |
getmove( /* get view change */ |
| 579 |
> |
XButtonPressedEvent *ebut |
| 580 |
> |
) |
| 581 |
|
{ |
| 582 |
|
int movdir = MOVDIR(ebut->button); |
| 583 |
|
int movorb = MOVORB(ebut->state); |
| 617 |
|
} |
| 618 |
|
|
| 619 |
|
|
| 620 |
< |
static |
| 621 |
< |
getkey(ekey) /* get input key */ |
| 622 |
< |
register XKeyPressedEvent *ekey; |
| 620 |
> |
static void |
| 621 |
> |
getkey( /* get input key */ |
| 622 |
> |
register XKeyPressedEvent *ekey |
| 623 |
> |
) |
| 624 |
|
{ |
| 625 |
|
int n; |
| 626 |
|
char buf[8]; |
| 689 |
|
} |
| 690 |
|
|
| 691 |
|
|
| 692 |
< |
static |
| 693 |
< |
fixwindow(eexp) /* repair damage to window */ |
| 694 |
< |
register XExposeEvent *eexp; |
| 692 |
> |
static void |
| 693 |
> |
fixwindow( /* repair damage to window */ |
| 694 |
> |
register XExposeEvent *eexp |
| 695 |
> |
) |
| 696 |
|
{ |
| 697 |
|
int xmin, xmax, ymin, ymax; |
| 698 |
|
|
| 715 |
|
} |
| 716 |
|
|
| 717 |
|
|
| 718 |
< |
static |
| 719 |
< |
resizewindow(ersz) /* resize window */ |
| 720 |
< |
register XConfigureEvent *ersz; |
| 718 |
> |
static void |
| 719 |
> |
resizewindow( /* resize window */ |
| 720 |
> |
register XConfigureEvent *ersz |
| 721 |
> |
) |
| 722 |
|
{ |
| 723 |
|
glViewport(0, 0, ersz->width, ersz->height); |
| 724 |
|
|