43 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
76 for (
int x = firstKey; ; x++)
86 for (
int x = 0; x < 256; x++)
99 for (
int x = 0; x < 256; x++)
104 keys.push_back(kd->title);
111 printf(
"Legal Keyboard Commands\n-----------------------\n");
112 for (
int x = 0; x < 256; x++)
116 printf(
"%s%c\t%s\t%s\n",
getModifierText(kd->mod), x, kd->title, kd->desc);
137 printf(
"Unknown keyboard command %s%c/%d\n\n",
getModifierText(mod), keyHit, keyHit);
166 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
208 const char *arg,
const char *param,
const char *usage)
215 printf(
"Valid command-line flags:\n\n");
234 for (
int y = 1; y < argc; )
247 printf(
"Error: unhandled command-line parameter (%s)\n\n", argv[y]);
311 printf(
"Cannot add viewport - reached limit of %d [constant MAXPORTS]\n",
MAXPORTS);
330 printf(
"Cannot add viewport - reached limit of %d [constant MAXPORTS]\n",
MAXPORTS);
354 return result.
x-result2.
x;
365 return result.
x-result2.
x;
414 where.
x = where.
x*2.0-1.0;
417 where.
y = -where.
y*2.0+1.0;
426 double xRatio = actualWidth/actualHeight;
427 double yRatio = actualHeight/actualWidth;
434 where.
x = where.
x*2.0-1.0;
440 where.
y = (-where.
y)*2.0+1.0;
484 printf(
"Unknown scale type\n");
493 where.
x = (where.
x+1.0)/2.0;
497 where.
y = -(where.
y-1.0)/2.0;
508 double xRatio = actualWidth/actualHeight;
509 double yRatio = actualHeight/actualWidth;
513 where.
x = (where.
x+1.0)/2.0;
518 where.
y = -(where.
y-1.0)/2.0;
557 printf(
"Unknown scale type\n");
566 for (
int x =
MAXPORTS-1; x >= 0; x--)
584 for (
int x =
MAXPORTS-1; x >= 0; x--)
688 for (
int y = 0; y < 4; y++)
731 for (
int y = 0; y < 4; y++)
775 void cameraLookAt(GLfloat x, GLfloat y, GLfloat z,
float cameraSpeed,
int port)
792 void cameraMoveTo(GLfloat x, GLfloat y, GLfloat z,
float cameraSpeed,
int port)
808 void cameraOffset(GLfloat x, GLfloat y, GLfloat z,
float cameraSpeed,
int port)
825 const double ratios[4][4][4] =
827 {{0, 0.5, 0, 1}, {0.5, 0.5, 0, 1}},
828 {{0, 0.5, 0.5, 0.5}, {0.5, 0.5, 0.5, 0.5}, {0, 1, 0, 0.5}},
829 {{0, 0.5, 0.5, 0.5}, {0.5, 0.5, 0.5, 0.5}, {0, 0.5, 0, 0.5}, {0.5, 0.5, 0, 0.5}}};
833 const double *val = ratios[0][currPort];
851 const double ratios[4][4][4] =
853 {{0, 0.5, 0, 1}, {0.5, 0.5, 0, 1}},
854 {{0, 0.5, 0.5, 0.5}, {0.5, 0.5, 0.5, 0.5}, {0, 1, 0, 0.5}},
855 {{0, 0.5, 0.5, 0.5}, {0.5, 0.5, 0.5, 0.5}, {0, 0.5, 0, 0.5}, {0.5, 0.5, 0, 0.5}}};
857 const double *val = ratios[0][currPort];
870 glMatrixMode(GL_PROJECTION);
882 GLdouble modelview[16];
883 GLdouble projection[16];
884 GLfloat winX, winY, winZ;
885 GLdouble posX, posY, posZ;
887 glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
888 glGetDoublev( GL_PROJECTION_MATRIX, projection );
889 glGetIntegerv( GL_VIEWPORT,
viewport );
891 winY = (float)
viewport[3] - (
float)y;
892 glReadPixels( x,
int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
900 return point3d(posX, posY, posZ);
906 if ((count <=
MAXPORTS) && (count > 0))
938 if ((which >= 0) && (which < pContextInfo->numPorts))
947 zero(0), bfOffBits(sizeof(
bmp_header)+2), biSize(40), biPlanes(1),
948 biBitCount(32), biCompression(0), biSizeImage(0), biXPelsPerMeter(2835), biYPelsPerMeter(2835),
949 biClrUsed(0), biClrImportant(0) {}
974 char file[strlen(filename)+5];
975 sprintf(file,
"%s.bmp", filename);
976 FILE *f = fopen(file,
"w+");
987 long rowBytes =
width * 4;
988 long imageSize = rowBytes *
height;
989 std::vector<char> image(imageSize);
991 char zero[4] = {0, 0, 0, 0};
992 glReadPixels(0, 0, GLsizei(
width), GLsizei(
height), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &image[0]);
997 int buffer = (4-
width%4)%4;
1000 uint16_t bfType = 19778;
1001 fwrite(&bfType,
sizeof(bfType), 1, f);
1003 for (
int x = 0; x <
height; x++)
1005 fwrite(&image[x*
width*4],
sizeof(
char),
width*4, f);
1007 fwrite(&zero,
sizeof(
char), buffer, f);
1043 void GetHeading(
unsigned long windowID,
int which, GLdouble &hx, GLdouble &hy, GLdouble &hz)
1048 for (
int x = 0; x < 4; x++)
1051 double xp, yp, zp, len, sa, ca;
1052 len = 1/sqrt(fRot[1]*fRot[1] +
1058 ca = cos(-fRot[0]*
PI/180.0);
1059 sa = sin(-fRot[0]*
PI/180.0);
1060 hx = (1-ca)*xp*zp+sa*yp;
1061 hy = (1-ca)*yp*zp-sa*xp;
1062 hz = ca+(1-ca)*zp*zp;
1063 len = 1/sqrt(hx*hx+hy*hy+hz*hz);