621int index1, index2, redIndex, blueIndex, greenIndex;
625 numColors =
g->numColors;
629 colors1[numColors].
red = 0;
630 colors1[numColors].
green = 0;
631 colors1[numColors].
blue = 0;
635 colors1[numColors + 1].
red = 255;
636 colors1[numColors + 1].
green = 0;
637 colors1[numColors + 1].
blue = 0;
641 colors1[numColors + 2].
red = 0;
642 colors1[numColors + 2].
green = 0;
643 colors1[numColors + 2].
blue = 255;
647 colors1[numColors + 3].
red = 255;
648 colors1[numColors + 3].
green = 0;
649 colors1[numColors + 3].
blue = 255;
653 for(index1 = 0; index1 < 256; index1++){
657 c.flags = DoRed | DoGreen | DoBlue;
660 g->cmapColors[0][index1] =
c;
661 g->cmapColors[1][index1] =
c;
662 g->cmapColors[2][index1] =
c;
667 colorIndex= numColors + 3;
672 while((index1 > 0) && (colorIndex >= 0)){
673 c.red = colors1[colorIndex].
red << 8;
674 c.green = colors1[colorIndex].
green << 8;
675 c.blue = colors1[colorIndex].
blue << 8;
676 c.flags = DoRed | DoGreen | DoBlue;
678 colors1[colorIndex].
value = index1 * 16 + index1;
681 ((
double)sqrt((
double)(
682 (
double)colors1[colorIndex].red * (
double)colors1[colorIndex].red +
683 (
double)colors1[colorIndex].green * (
double)colors1[colorIndex].green +
684 (
double)colors1[colorIndex].blue * (
double)colors1[colorIndex].blue))
687 for(index2 = 1; index2 < 16; index2++){
688 c.pixel = index2 * 16 + index1;
689 g->cmapColors[0][index2 * 16 + index1] =
c;
691 c.pixel = index1 * 16 + index2;
692 g->cmapColors[1][index1 * 16 + index2] =
c;
702 for(index1 = 0; index1 < 4; index1++){
703 c.red = colors1[numColors + index1].
red << 8;
704 c.green = colors1[numColors + index1].
green << 8;
705 c.blue = colors1[numColors + index1].
blue << 8;
706 c.flags = DoRed | DoGreen | DoBlue;
707 c.pixel = 12 + index1;
708 g->cmapColors[0][12 + index1] =
c;
709 g->cmapColors[1][12 + index1] =
c;
710 colors1[numColors + index1].
value =
c.pixel;
720 while(colorIndex < numColors){
721 if((index1 < 12) || (index1 > 15)){
722 c.red = colors1[colorIndex].
red << 8;
723 c.green = colors1[colorIndex].
green << 8;
724 c.blue = colors1[colorIndex].
blue << 8;
725 c.flags = DoRed | DoGreen | DoBlue;
727 g->cmapColors[0][index1] =
c;
728 g->cmapColors[1][index1] =
c;
729 colors1[colorIndex].
value = index1;
732 ((
double)sqrt((
double)(
733 (
double)colors1[colorIndex].red *
734 (
double)colors1[colorIndex].red +
735 (
double)colors1[colorIndex].green *
736 (
double)colors1[colorIndex].green +
737 (
double)colors1[colorIndex].blue *
738 (
double)colors1[colorIndex].blue))
758 c.flags = DoRed | DoGreen | DoBlue;
760 g->cmapColors[0][index1] =
c;
761 g->cmapColors[1][index1] =
c;
777 for(index1 = 0; index1 < numColors; index1++){
778 colors1[index1].
value = colors1[index1].
red * 36 +
779 colors1[index1].
green * 6 + colors1[index1].
blue + 17;
782 ((
double)sqrt((
double)(
783 (
double)colors1[colorIndex].red *
784 (
double)colors1[colorIndex].red +
785 (
double)colors1[colorIndex].green *
786 (
double)colors1[colorIndex].green +
787 (
double)colors1[colorIndex].blue *
788 (
double)colors1[colorIndex].blue))
798 for(redIndex = 0; redIndex < 4; redIndex++){
799 for(blueIndex = 0; blueIndex < 4; blueIndex++){
800 if(redIndex != blueIndex){
801 g->wireframeColors[0][index1] =
802 g->cmapColors[0][(redIndex + 12) * 16 + (blueIndex + 12)];
803 g->wireframeColors[1][index1] =
804 g->cmapColors[1][(redIndex + 12) * 16 + (blueIndex + 12)];
812 for(index1 = 13; index1 < 256; index1++){
813 g->wireframeColors[0][index1] =
g->wireframeColors[0][3];
814 g->wireframeColors[1][index1] =
g->wireframeColors[1][3];
819 for(redIndex = 0; redIndex < 15; redIndex++){
820 for(blueIndex = 0; blueIndex < 15; blueIndex++){
821 c.red = (redIndex * 17) << 8;
823 c.blue = (blueIndex * 17) << 8;
824 c.flags = DoRed | DoGreen | DoBlue;
825 c.pixel = (redIndex + 1) * 16 + (blueIndex + 1);
826 g->cmapColors[2][
c.pixel] =
c;
832 for(index1 = 0; index1 < numColors; index1++){
833 colorIndex = (
int)((
double)15 *
834 ((
double)sqrt((
double)((
double)colors1[index1].red *
835 (
double)colors1[index1].red + (
double)colors1[index1].green *
836 (
double)colors1[index1].green + (
double)colors1[index1].blue *
839 colors1[index1].
stereoColor = (colorIndex + 1) * 16 + (colorIndex + 1);
844 g->stereoBlack = (0 + 1) * 16 + (0 + 1);
847 g->Black = colors1[numColors].
value;
848 g->Red = colors1[numColors + 1].
value;
849 g->Blue = colors1[numColors + 2].
value;
850 g->Purple = colors1[numColors + 3].
value;
928{3, 1, 0, 1, 2, 3, 1},
929{4, 0, 1, 0, 3, 2, 1, 2, 3},
930{5, 0, 0, 0, 2, 2, 0, 2, 3, 3, 2},
931{6, 0, 2, 1, 1, 1, 3, 2, 0, 3, 1, 3, 3},
932{7, 0, 1, 0, 3, 1, 0, 1, 1, 2, 2, 3, 1, 3, 3},
933{8, 0, 1, 0, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 0, 3, 2},
934{9, 0, 0, 0, 2, 1, 2, 1, 3, 2, 0, 2, 1, 2, 3, 3, 1, 3, 2},
935{10,0, 0, 0, 1, 0, 3, 1, 0, 1, 2, 2, 1, 2, 2, 2, 3, 3, 0, 3, 2},
936{11,0, 1, 0, 3, 1, 0, 1, 1, 1, 2, 1, 3, 2, 1, 2, 2, 3, 0, 3, 2, 3, 3},
937{12,0, 0, 0, 2, 1, 0, 1, 1, 1, 2, 1, 3, 2, 1, 2, 3, 3, 0, 3, 1, 3, 2, 3, 3},
938{13,0, 0, 0, 2, 0, 3, 1, 0, 1, 1, 1, 2, 2, 0, 2, 2, 2, 3, 3, 0, 3, 1, 3, 2,
940{14,0, 0, 0, 1, 0, 2, 0, 3, 1, 0, 1, 1, 1, 3, 2, 1, 2, 2, 2, 3, 3, 0, 3, 1,
942{15,0, 0, 0, 1, 0, 2, 0, 3, 1, 0, 1, 2, 1, 3, 2, 0, 2, 1, 2, 2, 2, 3, 3, 0,
944{16,0, 0, 0, 1, 0, 2, 0, 3, 1, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 1, 2, 2, 2, 3,
945 3, 0, 3, 1, 3, 2, 3, 3}
952XWindowAttributes attributes;
955int index1, index2, screen;
968 if((
g->redColors = (
long *)
calloc(1, (numSegments + 4) * (
sizeof(
long))))
970(
void)fprintf(stderr,
"Unable to allocate memory for redColors\n");
return;}
972 if((
g->redSegments = (XSegment *)
calloc(1, (numSegments + 4) *
973 (
sizeof(XSegment)))) ==
NULL){
974(
void)fprintf(stderr,
"Unable to allocate memory for redSegments\n");
return;}
976 if((
g->blueSegments = (XSegment *)
calloc(1, (numSegments + 4) *
977 sizeof(XSegment))) == (XSegment *)
NULL){
978(
void)fprintf(stderr,
"Unable to allocate memory for blueSegments\n");
return;}
983 g->dpy = XOpenDisplay(
g->DisplayName);
987 fprintf(stderr,
"Cannot connect to server\n");
991 screen = DefaultScreen(
g->dpy);
992 g->black = (
long)BlackPixel(
g->dpy, screen);
993 g->white = (
long)WhitePixel(
g->dpy, screen);
998 g->dpyX = DisplayWidth(
g->dpy, screen);
999 g->dpyY = DisplayHeight(
g->dpy, screen);
1000 g->winX =
g->dpyX / 2;
1001 g->winY =
g->dpyY / 2 ;
1002 g->mono =
g->ColorSelect =
g->oldPointerX =
g->oldPointerY = 0;
1008 if((
g->font = XLoadQueryFont(
g->dpy,
FONT)) ==
NULL){
1009 fprintf(stderr,
"Unable to load font: %s ... trying fixed\n",
FONT);
1011 if((
g->font = XLoadQueryFont(
g->dpy,
FIXED)) ==
NULL){
1012 fprintf(stderr,
"Unable to load font: %s\n",
FIXED);
1018 fprintf(stderr,
"Unable to load font: %s ... trying fixed\n",
TITLEFONT);
1020 if((
g->titleFont = XLoadQueryFont(
g->dpy,
FIXED)) ==
NULL){
1021 fprintf(stderr,
"Unable to load font: %s\n",
FIXED);
1027 fprintf(stderr,
"Unable to load font: %s ... trying fixed\n",
BOLDFONT);
1029 if((
g->boldFont = XLoadQueryFont(
g->dpy,
FIXED)) ==
NULL){
1030 fprintf(stderr,
"Unable to load font: %s\n",
FIXED);
1038 g->depth = DefaultDepth(
g->dpy, screen);
1040 vis = DefaultVisual(
g->dpy, screen);
1041 if (
g->depth >
EIGHT && vis->class == TrueColor) {
1043 for (i = 0; i < (
int)
sizeof(vis->blue_mask)*8; i++) {
1044 if (
gBlueShift == -1 && ((vis->blue_mask >> i) & 1))
1046 if ((vis->blue_mask >> i) == 1) {
1051 for (i = 0; i < (
int)
sizeof(vis->green_mask)*8; i++) {
1052 if (
gGreenShift == -1 && ((vis->green_mask >> i) & 1))
1054 if ((vis->green_mask >> i) == 1) {
1059 for (i = 0; i < (
int)
sizeof(vis->red_mask)*8; i++) {
1060 if (
gRedShift == -1 && ((vis->red_mask >> i) & 1))
1062 if ((vis->red_mask >> i) == 1) {
1071 }
else if (
g->depth >
EIGHT)
1074 g->pix = XCreatePixmap(
g->dpy, RootWindow(
g->dpy,screen),
g->winX,
1085 g->helpWin = XCreateSimpleWindow(
g->dpy, RootWindow(
g->dpy, screen), 0, 0,
1086 g->helpWinX,
g->helpWinY, 0, 0, 0);
1089 g->win = XCreateSimpleWindow(
g->dpy, parent, 0, 0,
1090 g->winX,
g->winY, 0, 0, 0);
1092 g->win = XCreateSimpleWindow(
g->dpy, RootWindow(
g->dpy,screen), 0, 0,
1093 g->winX,
g->winY, 0, 0, 0);
1097 if(
g->Geometry && !useroot){
1103 sizehint.flags = USPosition | USSize;
1109 sizehint.width =
width;
1110 sizehint.height =
height;
1115 XSetNormalHints(
g->dpy,
g->win, &sizehint);
1120 g->winH = (
int)(
g->winX / 2.0);
1121 g->winV = (
int)(
g->winY / 2.0);
1125 g->gc = XCreateGC(
g->dpy,
g->win, 0x0,
NULL);
1126 g->helpGc = XCreateGC(
g->dpy,
g->helpWin, 0x0,
NULL);
1131 g->stipple[index1]= XCreateBitmapFromData(
g->dpy,
g->win, bits,
1133 temp_gc = XCreateGC(
g->dpy,
g->stipple[index1], 0x0,
NULL);
1134 XSetForeground(
g->dpy, temp_gc, 0);
1135 XFillRectangle(
g->dpy,
g->stipple[index1], temp_gc, 0, 0,
STIPPLESIZE,
1137 XSetForeground(
g->dpy, temp_gc, 1);
1138 for(index2 = 0; index2 < stipples[index1][0]; index2++){
1139 XDrawPoint(
g->dpy,
g->stipple[index1], temp_gc,
1140 stipples[index1][index2 * 2 + 1], stipples[index1][index2 * 2 + 2]);
1142 XFreeGC(
g->dpy, temp_gc);
1148 XSetInputFocus(
g->dpy, PointerRoot, RevertToNone, CurrentTime);
1156 wmhint.input =
True;
1157 wmhint.flags = InputHint;
1158 XSetWMHints(
g->dpy,
g->win,&wmhint);
1163 attribs.backing_store = NotUseful;
1164 XChangeWindowAttributes(
g->dpy,
g->win, CWBackingStore, &attribs);
1168 XSelectInput(
g->dpy,
g->win, ButtonPressMask | ButtonReleaseMask |
1169 KeyPressMask | Button1MotionMask | Button2MotionMask |
1170 StructureNotifyMask | ExposureMask | ColormapChangeMask);
1172 XSelectInput(
g->dpy,
g->helpWin, ButtonPressMask | ButtonReleaseMask |
1173 KeyPressMask | Button1MotionMask | Button2MotionMask |
1174 StructureNotifyMask | ExposureMask | ColormapChangeMask);
1179 XSetGraphicsExposures(
g->dpy,
g->gc, 0);
1183 XStoreName(
g->dpy,
g->win,
title);
1184 XStoreName(
g->dpy,
g->helpWin,
"ROOT://X3D/Help");
1189 XSetWindowBackground(
g->dpy,
g->win,
g->black);
1191 if(
g->depth ==
ONE){
1205 g->colormap = XCreateColormap(
g->dpy,
g->win, DefaultVisual(
g->dpy,
1210 XGetWindowAttributes(
g->dpy, RootWindow(
g->dpy,screen), &attributes);
1215 for(index1 = 0; index1 < NUMCOLORS; index1++)
1216 oldColormap[index1].
pixel = index1;
1218 XQueryColors(
g->dpy, attributes.colormap, oldColormap, NUMCOLORS);
1219 XStoreColors(
g->dpy,
g->colormap, oldColormap, NUMCOLORS);
1227 XStoreColors(
g->dpy,
g->colormap,
g->cmapColors[0], 256);
1228 XSetWindowColormap(
g->dpy,
g->helpWin,
g->colormap);
1229 XSetWindowColormap(
g->dpy,
g->win,
g->colormap);
1250 XMapWindow(
g->dpy,
g->win);
2487register int index1, npoints, numPolys;
2488register polygon *poly, **list1;
2489register point **pointPtr, **lastPointPtr;
2492_XPoint points1[512], *XPointPtr;
2493 void *ptrp = points1;
2498 sort(list1, numPolys);
2504 XSetForeground(
g->dpy,
g->gc,
g->black);
2508 for(index1 = 0; index1 < numPolys; index1++){
2510 poly = list1[index1];
2511 XPointPtr = points1;
2512 npoints = poly->numPoints;
2513 pointPtr = poly->points;
2514 lastPointPtr = &(poly->points[npoints]);
2516 while(pointPtr < lastPointPtr){
2517 *XPointPtr = (*pointPtr)->R;
2522 XSetForeground(
g->dpy,
g->gc,
g->black);
2523 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2525 points1[npoints] = points1[0];
2526 XSetForeground(
g->dpy,
g->gc,
g->white);
2527 XDrawLines(
g->dpy,
dest,
g->gc, ptrp, npoints + 1,
2531 XSetFillStyle(
g->dpy,
g->gc, FillSolid);
2536 XSetForeground(
g->dpy,
g->gc,
g->stereoBlack);
2540 XSetPlaneMask(
g->dpy,
g->gc,
g->redMask);
2542 for(index1 = 0; index1 < numPolys; index1++){
2543 poly = list1[index1];
2544 XPointPtr = points1;
2545 npoints = poly->numPoints;
2546 pointPtr = poly->points;
2547 lastPointPtr = &(poly->points[npoints]);
2549 while(pointPtr < lastPointPtr){
2550 *XPointPtr = (*pointPtr)->R;
2555 XSetForeground(
g->dpy,
g->gc,
g->stereoBlack);
2556 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2558 points1[npoints] = points1[0];
2559 XSetForeground(
g->dpy,
g->gc, poly->color->stereoColor);
2560 XDrawLines(
g->dpy,
dest,
g->gc, ptrp, npoints + 1,
2565 XSetPlaneMask(
g->dpy,
g->gc,
g->blueMask);
2567 for(index1 = 0; index1 < numPolys; index1++){
2568 poly = list1[index1];
2569 XPointPtr = points1;
2570 npoints = poly->numPoints;
2571 pointPtr = poly->points;
2572 lastPointPtr = &(poly->points[npoints]);
2574 while(pointPtr < lastPointPtr){
2575 XPointPtr->
x = (*pointPtr)->sBX;
2576 XPointPtr->
y = (*pointPtr)->R.y;
2581 XSetForeground(
g->dpy,
g->gc,
g->stereoBlack);
2582 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2584 points1[npoints] = points1[0];
2585 XSetForeground(
g->dpy,
g->gc, poly->color->stereoColor);
2586 XDrawLines(
g->dpy,
dest,
g->gc, ptrp, npoints + 1,
2590 XSetPlaneMask(
g->dpy,
g->gc, AllPlanes);
2595 XSetForeground(
g->dpy,
g->gc,
g->Black);
2599 for(index1 = 0; index1 < numPolys; index1++){
2600 poly = list1[index1];
2601 XPointPtr = points1;
2602 npoints = poly->numPoints;
2603 pointPtr = poly->points;
2604 lastPointPtr = &(poly->points[npoints]);
2606 while(pointPtr < lastPointPtr){
2607 *XPointPtr = (*pointPtr)->R;
2612 XSetForeground(
g->dpy,
g->gc,
g->Black);
2613 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2616 points1[npoints] = points1[0];
2617 XSetForeground(
g->dpy,
g->gc, poly->color->value);
2618 XDrawLines(
g->dpy,
dest,
g->gc, ptrp, npoints + 1,
2636register int index1, npoints, numPolys;
2637register polygon *poly, **list1;
2638register point **pointPtr, **lastPointPtr;
2640_XPoint points1[512], *XPointPtr;
2643 void *ptrp = points1;
2648 sort(list1, numPolys);
2654 XSetForeground(
g->dpy,
g->gc,
g->black);
2657 XSetForeground(
g->dpy,
g->gc,
g->white);
2658 XSetBackground(
g->dpy,
g->gc,
g->black);
2659 XSetFillStyle(
g->dpy,
g->gc, FillOpaqueStippled);
2661 for(index1 = 0; index1 < numPolys; index1++){
2663 poly = list1[index1];
2664 XPointPtr = points1;
2665 XSetStipple(
g->dpy,
g->gc,
g->stipple[poly->color->stipple]);
2666 npoints = poly->numPoints;
2667 pointPtr = poly->points;
2668 lastPointPtr = &(poly->points[npoints]);
2670 while(pointPtr < lastPointPtr){
2671 *XPointPtr = (*pointPtr)->R;
2676 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2680 XSetFillStyle(
g->dpy,
g->gc, FillSolid);
2685 XSetForeground(
g->dpy,
g->gc,
g->stereoBlack);
2688 lastColor =
g->stereoBlack;
2690 XSetPlaneMask(
g->dpy,
g->gc,
g->redMask);
2692 for(index1 = 0; index1 < numPolys; index1++){
2693 poly = list1[index1];
2694 XPointPtr = points1;
2695 if(poly->color->stereoColor != lastColor){
2696 XSetForeground(
g->dpy,
g->gc, poly->color->stereoColor);
2697 lastColor = poly->color->stereoColor;
2699 npoints = poly->numPoints;
2700 pointPtr = poly->points;
2701 lastPointPtr = &(poly->points[npoints]);
2703 while(pointPtr < lastPointPtr){
2704 *XPointPtr = (*pointPtr)->R;
2709 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2714 XSetPlaneMask(
g->dpy,
g->gc,
g->blueMask);
2716 for(index1 = 0; index1 < numPolys; index1++){
2717 poly = list1[index1];
2718 XPointPtr = points1;
2719 if(poly->color->stereoColor != lastColor){
2720 XSetForeground(
g->dpy,
g->gc, poly->color->stereoColor);
2721 lastColor = poly->color->stereoColor;
2723 npoints = poly->numPoints;
2724 pointPtr = poly->points;
2725 lastPointPtr = &(poly->points[npoints]);
2727 while(pointPtr < lastPointPtr){
2728 XPointPtr->
x = (*pointPtr)->sBX;
2729 XPointPtr->
y = (*pointPtr)->R.y;
2734 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,
2738 XSetPlaneMask(
g->dpy,
g->gc, AllPlanes);
2743 XSetForeground(
g->dpy,
g->gc,
g->Black);
2746 lastColor =
g->Black;
2748 for(index1 = 0; index1 < numPolys; index1++){
2749 poly = list1[index1];
2750 XPointPtr = points1;
2751 if(poly->color->value != lastColor){
2752 XSetForeground(
g->dpy,
g->gc, poly->color->value);
2753 lastColor = poly->color->value;
2755 npoints = poly->numPoints;
2756 pointPtr = poly->points;
2757 lastPointPtr = &(poly->points[npoints]);
2759 while(pointPtr < lastPointPtr){
2760 *XPointPtr = (*pointPtr)->R;
2765 XFillPolygon(
g->dpy,
dest,
g->gc, ptrp, npoints, Convex,