GLES2

Check-in [d76bff8039]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes for doing real 3D borders for buttons
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d76bff803955436080c483359a0d307732cc8170
User & Date: arnulf 2013-08-30 21:09:43
Context
2013-08-31
11:11
fixes for 3D displaying of borders check-in: d0c312bca6 user: arnulf tags: trunk
2013-08-30
21:09
fixes for doing real 3D borders for buttons check-in: d76bff8039 user: arnulf tags: trunk
2013-08-25
16:55
typo fix check-in: bef12e00c8 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/gles2Builtin.c.

221
222
223
224
225
226
227

228
229

230
231
232
233
234
235
236
...
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
...
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
...
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
...
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
....
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
....
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
....
1570
1571
1572
1573
1574
1575
1576





1577
1578
1579
1580
1581
1582
1583
1584
1585
1586






1587
1588
1589
1590
1591
1592
1593
....
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667








1668







1669






1670
1671
1672
1673
1674
1675
1676
    double light_blue;
    double light_alpha;
} shadowColors;

typedef struct {
    int x;
    int y;

    int width;
    int height;

} positionBox;

GLuint _colorRenderBuffer;
GLuint framebuffer;
GLuint vertexBuffer;
GLuint indexBuffer;
GLuint _positionSlot;
................................................................................
		}
	    }
#endif
	}
    }
}

void VerticalBevel(Tcl_Interp *interp, int x, int y, int width, int height, int leftBevel, char *relief, shadowColors shadow_colors) {
    Tcl_Obj *obj;
    Tcl_Obj *cmd_obj;
    Tcl_Obj *cmd_objv[1];

//fprintf(stderr, "VerticalBevel!x!%d!y!%d!width!%d!height!%d!relief!%s!\n", x, y, width, height, relief);
    if (strcmp(relief, "raised") == 0) {
	if (leftBevel) {
            obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.light_red,
                shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha);  
	} else {
            obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.dark_red,
                shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha);  
	}
        cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	cmd_objv[0] = cmd_obj;
	if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
//fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
            exit(1);
	}
//fprintf(stderr, "obj!%s!\n", Tcl_GetString(obj));
        if (Tcl_EvalObjEx(interp, obj, 0) != TCL_OK) {
//fprintf(stderr, "VerticalBevel: error in executing fillrectangle command:%s\n", Tcl_GetStringResult(interp));
            exit(1);
	}
//        XFillRectangle(display, drawable,
//            (leftBevel) ? borderPtr->lightGC : borderPtr->darkGC,
//            x, y, (unsigned) width, (unsigned) height);
    } else {
        if (strcmp(relief, "sunken") == 0) {
//            XFillRectangle(display, drawable,
//               (leftBevel) ? borderPtr->darkGC : borderPtr->lightGC,
//               x, y, (unsigned) width, (unsigned) height);
	    if (leftBevel) {
                obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.dark_red,
                    shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha);  
	    } else {
                obj = BuildVertexInfo(interp, x, y, width, height, shadow_colors.light_red,
                    shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha);  
	    }
            cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	    cmd_objv[0] = cmd_obj;
	    if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
                exit(1);
	    }
................................................................................
		}
	    }
#endif
	}
    }
}

void HorizontalBevel(Tcl_Interp * interp, int x, int y, int width, int height, int leftIn, int rightIn, int topBevel, char *relief, shadowColors shadow_colors) {
    Tcl_Obj *obj;
    Tcl_Obj *cmd_obj;
    Tcl_Obj *cmd_objv[1];
    int x1;
    int x2;
    int x1Delta;
    int x2Delta;
................................................................................
    int bottomGC;
    int myGC;
#define GC_DARK 1
#define GC_LITE 2
#define GC_BRDR 3
#define GC_BLAK 4

//fprintf(stderr, "HorizontalBevel!x!%d!y!%d!width!%d!height!%d!relief!%s!\n", x, y, width, height, relief);
    topGC = GC_BLAK;
    bottomGC = GC_BLAK;
    if (strcmp(relief, "raised") == 0) {
        if (topBevel) {
            topGC = GC_LITE;
            bottomGC = GC_LITE;
	} else {
................................................................................
            if (y < halfway) {
	        myGC = topGC;
	    } else {
                myGC = bottomGC;
	    }
	    switch (myGC) {
            case GC_LITE:
                    obj = BuildVertexInfo(interp, x1, y, x2-x1, 1, shadow_colors.light_red,
                        shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha);  
        
	        break;
            case GC_DARK:
                    obj = BuildVertexInfo(interp, x1, y, x2-x1, 1, shadow_colors.dark_red,
                        shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha);  
		break;
            case GC_BRDR:
            case GC_BLAK:
fprintf(stderr, "GC_BRDR and GC_BLAK not yet implemented!!\n");
                exit(1);
		break;
            default:
................................................................................
 * ------------------------------------------------------------------------
 *  Gles2_BiDrawRectangleBorderCmd()
 *
 *  Invoked to handle the "drawrectangleborder" command
 *  Handles the
 *  following syntax:
 *
 *    drawrectangleborder [list x y width height] borderWidth relief
 *        [list darkColor lightColor]
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiDrawRectangleBorderCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
................................................................................
        Tcl_WrongNumArgs(interp, 1, objv, "box borderWidth relief shadowColors");
        return TCL_ERROR;
    }
    if (Tcl_ListObjGetElements(interp, objv[1], &box_objc, &boxObjv) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawRectangleBorderCmd1: bad input format: %s\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
    }
    if (box_objc != 4) {
fprintf(stderr, "Gles2_BiDrawRectangleBorderCmd2: bad input format: %s %d\n", Tcl_GetString(objv[1]), box_objc);
        return TCL_ERROR;
    }

    /* x */
    if (Tcl_GetIntFromObj(interp, boxObjv[0], &position_box.x) != TCL_OK) {
fprintf(stderr, "bad value for x!%s!\n", Tcl_GetString(boxObjv[0]));
................................................................................
        return TCL_ERROR;
    }
    /* y */
    if (Tcl_GetIntFromObj(interp, boxObjv[1], &position_box.y) != TCL_OK) {
fprintf(stderr, "bad value for y!%s!\n", Tcl_GetString(boxObjv[1]));
        return TCL_ERROR;
    }





    /* width */
    if (Tcl_GetIntFromObj(interp, boxObjv[2], &position_box.width) != TCL_OK) {
fprintf(stderr, "bad value for width!%s!\n", Tcl_GetString(boxObjv[2]));
        return TCL_ERROR;
    }
    /* height */
    if (Tcl_GetIntFromObj(interp, boxObjv[3], &position_box.height) != TCL_OK) {
fprintf(stderr, "bad value for height!%s!\n", Tcl_GetString(boxObjv[3]));
        return TCL_ERROR;
    }






    /* borderWidth */
    if (Tcl_GetIntFromObj(interp, objv[2], &borderWidth) != TCL_OK) {
fprintf(stderr, "bad value for borderWidth!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    relief = Tcl_GetString(objv[3]);

................................................................................
    }
    if (position_box.width < 2*borderWidth) {
        borderWidth = position_box.width/2;
    }
    if (position_box.height < 2*borderWidth) {
        borderWidth = position_box.height/2;
    }
    VerticalBevel(interp, position_box.x, position_box.y, borderWidth, position_box.height, 1, relief, shadow_colors);
    VerticalBevel(interp, position_box.x+position_box.width-borderWidth, position_box.y, borderWidth, position_box.height, 0, relief, shadow_colors);
//    HorizontalBevel(interp, position_box.x, position_box.y, position_box.width, borderWidth, 1, 1, 1, relief, shadow_colors);








    HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.width, borderWidth, 1, 1, 1, relief, shadow_colors);







    HorizontalBevel(interp, position_box.x, position_box.y, position_box.width, borderWidth, 0, 0, 0, relief, shadow_colors);







    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiDrawDiamondBorderCmd()







>


>







 







|




|


|
|

|
|







|













|
|

|
|







 







|







 







|







 







|
|



|
|







 







|







 







|







 







>
>
>
>
>

|
|



|
|


>
>
>
>
>
>







 







|
|
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>







221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
...
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
...
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
...
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
...
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
....
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
....
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
....
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
....
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
    double light_blue;
    double light_alpha;
} shadowColors;

typedef struct {
    int x;
    int y;
    int z;
    int width;
    int height;
    int depth;
} positionBox;

GLuint _colorRenderBuffer;
GLuint framebuffer;
GLuint vertexBuffer;
GLuint indexBuffer;
GLuint _positionSlot;
................................................................................
		}
	    }
#endif
	}
    }
}

void VerticalBevel(Tcl_Interp *interp, int x, int y, int z, int width, int height, int depth, int leftBevel, char *relief, shadowColors shadow_colors, int side) {
    Tcl_Obj *obj;
    Tcl_Obj *cmd_obj;
    Tcl_Obj *cmd_objv[1];

fprintf(stderr, "VerticalBevel!x!%d!y!%d!z!%d!width!%d!height!%d!depth!%d!relief!%s!\n", x, y, z, width, height, depth, relief);
    if (strcmp(relief, "raised") == 0) {
	if (leftBevel) {
            obj = BuildVertexInfo(interp, x, y, z, width, height, depth, shadow_colors.light_red,
                shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha, side);  
	} else {
            obj = BuildVertexInfo(interp, x, y, z, width, height, depth, shadow_colors.dark_red,
                shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha, side);  
	}
        cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	cmd_objv[0] = cmd_obj;
	if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
//fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
            exit(1);
	}
fprintf(stderr, "obj!%s!\n", Tcl_GetString(obj));
        if (Tcl_EvalObjEx(interp, obj, 0) != TCL_OK) {
//fprintf(stderr, "VerticalBevel: error in executing fillrectangle command:%s\n", Tcl_GetStringResult(interp));
            exit(1);
	}
//        XFillRectangle(display, drawable,
//            (leftBevel) ? borderPtr->lightGC : borderPtr->darkGC,
//            x, y, (unsigned) width, (unsigned) height);
    } else {
        if (strcmp(relief, "sunken") == 0) {
//            XFillRectangle(display, drawable,
//               (leftBevel) ? borderPtr->darkGC : borderPtr->lightGC,
//               x, y, (unsigned) width, (unsigned) height);
	    if (leftBevel) {
                obj = BuildVertexInfo(interp, x, y, z, width, height, depth, shadow_colors.dark_red,
                    shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha, side);  
	    } else {
                obj = BuildVertexInfo(interp, x, y, z, width, height, depth, shadow_colors.light_red,
                    shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha, side);  
	    }
            cmd_obj = Tcl_NewStringObj("::gles2::builtin::fillrectangle", -1);
	    cmd_objv[0] = cmd_obj;
	    if (Tcl_ListObjReplace(interp, obj, 0, 0, 1, cmd_objv) != TCL_OK) {
fprintf(stderr, "VerticalBevel: cannot insert command in front of vertex info\n");
                exit(1);
	    }
................................................................................
		}
	    }
#endif
	}
    }
}

void HorizontalBevel(Tcl_Interp * interp, int x, int y, int z, int width, int height, int depth, int leftIn, int rightIn, int topBevel, char *relief, shadowColors shadow_colors, int side) {
    Tcl_Obj *obj;
    Tcl_Obj *cmd_obj;
    Tcl_Obj *cmd_objv[1];
    int x1;
    int x2;
    int x1Delta;
    int x2Delta;
................................................................................
    int bottomGC;
    int myGC;
#define GC_DARK 1
#define GC_LITE 2
#define GC_BRDR 3
#define GC_BLAK 4

fprintf(stderr, "HorizontalBevel!x!%d!y!%d!z!%d!width!%d!height!%d!depth!%d!relief!%s!leftIn!%d!rightIn!%d!\n", x, y, z, width, height, depth, relief, leftIn, rightIn);
    topGC = GC_BLAK;
    bottomGC = GC_BLAK;
    if (strcmp(relief, "raised") == 0) {
        if (topBevel) {
            topGC = GC_LITE;
            bottomGC = GC_LITE;
	} else {
................................................................................
            if (y < halfway) {
	        myGC = topGC;
	    } else {
                myGC = bottomGC;
	    }
	    switch (myGC) {
            case GC_LITE:
                    obj = BuildVertexInfo(interp, x1, y, z, x2-x1, 1, depth, shadow_colors.light_red,
                        shadow_colors.light_green, shadow_colors.light_blue, shadow_colors.light_alpha, side);
        
	        break;
            case GC_DARK:
                    obj = BuildVertexInfo(interp, x1, y, z, x2-x1, 1, depth, shadow_colors.dark_red,
                        shadow_colors.dark_green, shadow_colors.dark_blue, shadow_colors.dark_alpha, side);
		break;
            case GC_BRDR:
            case GC_BLAK:
fprintf(stderr, "GC_BRDR and GC_BLAK not yet implemented!!\n");
                exit(1);
		break;
            default:
................................................................................
 * ------------------------------------------------------------------------
 *  Gles2_BiDrawRectangleBorderCmd()
 *
 *  Invoked to handle the "drawrectangleborder" command
 *  Handles the
 *  following syntax:
 *
 *    drawrectangleborder [list x y z width height depth] borderWidth relief
 *        [list darkColor lightColor]
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiDrawRectangleBorderCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
................................................................................
        Tcl_WrongNumArgs(interp, 1, objv, "box borderWidth relief shadowColors");
        return TCL_ERROR;
    }
    if (Tcl_ListObjGetElements(interp, objv[1], &box_objc, &boxObjv) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawRectangleBorderCmd1: bad input format: %s\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
    }
    if (box_objc != 6) {
fprintf(stderr, "Gles2_BiDrawRectangleBorderCmd2: bad input format: %s %d\n", Tcl_GetString(objv[1]), box_objc);
        return TCL_ERROR;
    }

    /* x */
    if (Tcl_GetIntFromObj(interp, boxObjv[0], &position_box.x) != TCL_OK) {
fprintf(stderr, "bad value for x!%s!\n", Tcl_GetString(boxObjv[0]));
................................................................................
        return TCL_ERROR;
    }
    /* y */
    if (Tcl_GetIntFromObj(interp, boxObjv[1], &position_box.y) != TCL_OK) {
fprintf(stderr, "bad value for y!%s!\n", Tcl_GetString(boxObjv[1]));
        return TCL_ERROR;
    }
    /* z */
    if (Tcl_GetIntFromObj(interp, boxObjv[2], &position_box.z) != TCL_OK) {
fprintf(stderr, "bad value for z!%s!\n", Tcl_GetString(boxObjv[2]));
        return TCL_ERROR;
    }
    /* width */
    if (Tcl_GetIntFromObj(interp, boxObjv[3], &position_box.width) != TCL_OK) {
fprintf(stderr, "bad value for width!%s!\n", Tcl_GetString(boxObjv[3]));
        return TCL_ERROR;
    }
    /* height */
    if (Tcl_GetIntFromObj(interp, boxObjv[4], &position_box.height) != TCL_OK) {
fprintf(stderr, "bad value for height!%s!\n", Tcl_GetString(boxObjv[4]));
        return TCL_ERROR;
    }
    /* depth */
    if (Tcl_GetIntFromObj(interp, boxObjv[5], &position_box.depth) != TCL_OK) {
fprintf(stderr, "bad value for depth!%s!\n", Tcl_GetString(boxObjv[5]));
        return TCL_ERROR;
    }
fprintf(stderr, "POS!%d!%d!%d %d!%d!%d!\n", position_box.x, position_box.y, position_box.z, position_box.width, position_box.height, position_box.depth);
    /* borderWidth */
    if (Tcl_GetIntFromObj(interp, objv[2], &borderWidth) != TCL_OK) {
fprintf(stderr, "bad value for borderWidth!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    relief = Tcl_GetString(objv[3]);

................................................................................
    }
    if (position_box.width < 2*borderWidth) {
        borderWidth = position_box.width/2;
    }
    if (position_box.height < 2*borderWidth) {
        borderWidth = position_box.height/2;
    }
    VerticalBevel(interp, position_box.x, position_box.y, position_box.z, borderWidth, position_box.height, position_box.depth, 1, relief, shadow_colors, FRONT_SIDE);
    if (position_box.depth > 0) {
        VerticalBevel(interp, position_box.x, position_box.y, position_box.z, borderWidth, position_box.height, position_box.depth, 1, relief, shadow_colors, RIGHT_SIDE);
        VerticalBevel(interp, position_box.x, position_box.y, position_box.z, borderWidth, position_box.height, position_box.depth, 1, relief, shadow_colors, LEFT_SIDE);
    }
    VerticalBevel(interp, position_box.x+position_box.width-borderWidth, position_box.y, position_box.z, borderWidth, position_box.height, position_box.depth, 0, relief, shadow_colors, FRONT_SIDE);
    if (position_box.depth > 0) {
        VerticalBevel(interp, position_box.x+position_box.width-borderWidth, position_box.y, position_box.z, borderWidth, position_box.height, position_box.depth, 0, relief, shadow_colors, RIGHT_SIDE);
        VerticalBevel(interp, position_box.x+position_box.width-borderWidth, position_box.y, position_box.z, borderWidth, position_box.height, position_box.depth, 0, relief, shadow_colors, LEFT_SIDE);
    }
fprintf(stderr, "1\n");
    HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.z, position_box.width, borderWidth, position_box.depth, 1, 1, 1, relief, shadow_colors, FRONT_SIDE);
    if (position_box.depth > 0) {
fprintf(stderr, "2\n");
        HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.z, position_box.width, borderWidth, position_box.depth, 1, 1, 1, relief, shadow_colors, TOP_SIDE);
        HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.z, position_box.width, borderWidth, position_box.depth, 1, 1, 1, relief, shadow_colors, BOTTOM_SIDE);
        HorizontalBevel(interp, position_box.x, position_box.y+position_box.height-borderWidth, position_box.z, position_box.width, borderWidth, position_box.depth, 1, 1, 1, relief, shadow_colors, BACK_SIDE);
    }
fprintf(stderr, "3\n");
    HorizontalBevel(interp, position_box.x, position_box.y, position_box.z, position_box.width, borderWidth, position_box.depth, 0, 0, 0, relief, shadow_colors, FRONT_SIDE);
    if (position_box.depth > 0) {
fprintf(stderr, "4\n");
        HorizontalBevel(interp, position_box.x, position_box.y, position_box.z, position_box.width, borderWidth, position_box.depth, 0, 0, 0, relief, shadow_colors, TOP_SIDE);
        HorizontalBevel(interp, position_box.x, position_box.y, position_box.z, position_box.width, borderWidth, position_box.depth, 0, 0, 0, relief, shadow_colors, BOTTOM_SIDE);
        HorizontalBevel(interp, position_box.x, position_box.y, position_box.z, position_box.width, borderWidth, position_box.depth, 0, 0, 0, relief, shadow_colors, BACK_SIDE);
    }

    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiDrawDiamondBorderCmd()

Changes to generic/gles2Helpers.c.

303
304
305
306
307
308
309
310
311
312
313
314

315



316
317
318
319
320
321
322
...
991
992
993
994
995
996
997











































































998
999
1000
1001
1002
1003
1004
....
1007
1008
1009
1010
1011
1012
1013

1014
1015

1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218







1219
1220
1221
1222
1223
1224
1225
 * ------------------------------------------------------------------------
 */

GLfloat
Pixel2Coord(
    Tcl_Interp *interp,      /* current interpreter */
    int pixels,              /* width or height in pixels */
    int useWidth)            /* whether to use width or height */
{
    if (useWidth) {
        return pixels * 4.0 / uiWidth;
    } else {

        return pixels * 4.0 / uiHeight;



    }
}

/*
 * ------------------------------------------------------------------------
 *  Value2Pixel()
 *
................................................................................
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetElementPositions could not append light_color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    return listObj;
}












































































/*
 * ------------------------------------------------------------------------
 *  BuildVertexInfo()
 *
 *  the Vertex info is delivered as:
 *      x y z r g b @
................................................................................
 */

Tcl_Obj *
BuildVertexInfo(
    Tcl_Interp *interp,      /* current interpreter */
    int x,                   /* x coord */
    int y,                   /* y coord */

    int width,               /* width */
    int height,              /* height */

    double red,              /* red part */
    double green,            /* green part */
    double blue,             /* blue part */
    double alpha)            /* alpha part */
{
    Tcl_Obj *obj;
    Tcl_Obj *listObj;
    Tcl_Obj *list1Obj;

//red = 1.0;
//green = 0.0;
//blue = 0.0;
    obj = Tcl_NewListObj(0, NULL); /* the return obj */
    listObj = Tcl_NewListObj(0, NULL); /* the pos1 obj */

    /* position1 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp,x, 1))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append x value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, y, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(Pixel2Coord(interp, 0, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append position1 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* color */
    list1Obj = Tcl_NewListObj(0, NULL); /* the color obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(red)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_red value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(green)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_green value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(blue)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_blue value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(alpha)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append alpha value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, obj, listObj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append pos1: %s\n", Tcl_GetString(listObj));
        return NULL;
    }

    listObj = Tcl_NewListObj(0, NULL); /* the pos2 obj */
    /* position2 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, x+width, 1))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append x value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, y, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(Pixel2Coord(interp, 0, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append position1 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* color */
    list1Obj = Tcl_NewListObj(0, NULL); /* the color obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(red)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_red value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(green)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_green value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(blue)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_blue value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(alpha)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append alpha value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, obj, listObj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append pos2: %s\n", Tcl_GetString(listObj));
        return NULL;
    }

    listObj = Tcl_NewListObj(0, NULL); /* the pos3 obj */
    /* position3 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, x+width, 1))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append x value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, y+height, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(Pixel2Coord(interp, 0, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append position1 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* color */
    list1Obj = Tcl_NewListObj(0, NULL); /* the color obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(red)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_red value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(green)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_green value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(blue)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_blue value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(alpha)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append alpha value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, obj, listObj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append pos3: %s\n", Tcl_GetString(listObj));
        return NULL;
    }

    listObj = Tcl_NewListObj(0, NULL); /* the pos4 obj */
    /* position4 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, x, 1))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append x value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1+Pixel2Coord(interp, y+height, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(Pixel2Coord(interp, 0, 0))) != TCL_OK) {
fprintf(stderr, "GetShadows could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append position1 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* color */
    list1Obj = Tcl_NewListObj(0, NULL); /* the color obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(red)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_red value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(green)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_green value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(blue)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_blue value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(alpha)) != TCL_OK) {
fprintf(stderr, "GetShadows could not append alpha value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append dark_color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, obj, listObj) != TCL_OK) {
fprintf(stderr, "GetShadows could not append pos4: %s\n", Tcl_GetString(listObj));
        return NULL;
    }









    return obj;

}

/*
 * ------------------------------------------------------------------------
 *  showMatrix()







|

|


>
|
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>


>



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>







303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
...
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
....
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
 * ------------------------------------------------------------------------
 */

GLfloat
Pixel2Coord(
    Tcl_Interp *interp,      /* current interpreter */
    int pixels,              /* width or height in pixels */
    int useWidth)            /* whether to use width > 0 or height == 0 or for z < 0*/
{
    if (useWidth > 0) {
        return pixels * 4.0 / uiWidth;
    } else {
        if (useWidth == 0) {
            return pixels * 4.0 / uiHeight;
        } else {
            return pixels / 100.0 + 1;
        }
    }
}

/*
 * ------------------------------------------------------------------------
 *  Value2Pixel()
 *
................................................................................
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "GetElementPositions could not append light_color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    return listObj;
}

/*
 * ------------------------------------------------------------------------
 *  AppendVertexPos()
 *
 *  the Vertex info is delivered as:
 *      x y z r g b @
 *  result is [list [list x y z] [list r g b @]]
 * ------------------------------------------------------------------------
 */

Tcl_Obj *
AppendVertexPos(
    Tcl_Interp *interp,      /* current interpreter */
    double x,                /* x coord */
    double y,                /* y coord */
    double z,                /* z coord */
    Tcl_Obj *redObj,         /* red part */
    Tcl_Obj *greenObj,       /* green part */
    Tcl_Obj *blueObj,        /* blue part */
    Tcl_Obj *alphaObj,       /* alpha part */
    Tcl_Obj *obj)            /* Tcl_Obj to appen to */
{
    Tcl_Obj *listObj;
    Tcl_Obj *list1Obj;

fprintf(stderr, "AppendVertexPos!%f!%f!%f!\n", x, y, z);
    listObj = Tcl_NewListObj(0, NULL); /* the pos obj */

    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(x)) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append x value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(y)) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append y value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(z)) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append z value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append position1 value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }

    /* color */
    list1Obj = Tcl_NewListObj(0, NULL); /* the color obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, redObj) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append dark_red value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, greenObj) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append dark_green value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, blueObj) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append dark_blue value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, list1Obj, alphaObj) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append alpha value: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, list1Obj) != TCL_OK) {
fprintf(stderr, "BuildVertexInfoPos could not append color value: %s\n", Tcl_GetString(list1Obj));
        return NULL;
    }
    if (Tcl_ListObjAppendElement(interp, obj, listObj) != TCL_OK) {
fprintf(stderr, "GBuildVertexInfoPos could not append pos: %s\n", Tcl_GetString(listObj));
        return NULL;
    }
    return listObj;
}

/*
 * ------------------------------------------------------------------------
 *  BuildVertexInfo()
 *
 *  the Vertex info is delivered as:
 *      x y z r g b @
................................................................................
 */

Tcl_Obj *
BuildVertexInfo(
    Tcl_Interp *interp,      /* current interpreter */
    int x,                   /* x coord */
    int y,                   /* y coord */
    int z,                   /* z coord */
    int width,               /* width */
    int height,              /* height */
    int depth,               /* depth */
    double red,              /* red part */
    double green,            /* green part */
    double blue,             /* blue part */
    double alpha,            /* alpha part */
    int side)                /* which side of cube */
{
    Tcl_Obj *obj;
    Tcl_Obj *redObj;
    Tcl_Obj *greenObj;
    Tcl_Obj *blueObj;
    Tcl_Obj *alphaObj;
    double f_x;
    double f_y;
    double f_z;

//red = 1.0;
//green = 0.0;
//blue = 0.0;
    redObj = Tcl_NewDoubleObj(red);
    greenObj = Tcl_NewDoubleObj(green);
    blueObj = Tcl_NewDoubleObj(blue);
    alphaObj = Tcl_NewDoubleObj(alpha);

fprintf(stderr, "BuildVertexInfo!%d! %d!%d!%d! %d!%d!%d!\n", side, x, y, z, width, height, depth);
    obj = Tcl_NewListObj(0, NULL); /* the return obj */
    switch(side) {
    case FRONT_SIDE:
        /* position1 */
        f_x = -1+Pixel2Coord(interp,x, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position2 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position3 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position4 */
        f_x = -1+Pixel2Coord(interp, x, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
	break;
    case RIGHT_SIDE:
        /* position1 */
        f_x = -1+Pixel2Coord(interp,x, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position2 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position3 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position4 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
	break;
    case TOP_SIDE:
        /* position1 */
        f_x = -1+Pixel2Coord(interp,x, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position2 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position3 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position4 */
        f_x = -1+Pixel2Coord(interp, x, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
	break;
    case LEFT_SIDE:
        /* position1 */
        f_x = -1+Pixel2Coord(interp,x, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position2 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position3 */
        f_x = -1+Pixel2Coord(interp, x, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position4 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
	break;
    case BOTTOM_SIDE:
        /* position1 */
        f_x = -1+Pixel2Coord(interp,x, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position2 */
        f_x = -1+Pixel2Coord(interp, x, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position3 */
        f_x = -1+Pixel2Coord(interp, x, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position4 */
        f_x = -1+Pixel2Coord(interp, x, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
	break;
    case BACK_SIDE:
        /* position1 */
        f_x = -1+Pixel2Coord(interp,x+width, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position2 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position3 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
        /* position4 */
        f_x = -1+Pixel2Coord(interp, x+width, 1);
        f_y = -1+Pixel2Coord(interp, y+height, 0);
        f_z = -1+Pixel2Coord(interp, z-depth, -1);
        if (AppendVertexPos(interp, f_x, f_y, f_z, redObj, greenObj, blueObj, alphaObj, obj) == NULL) {
            return NULL;
        }
	break;
    default:
fprintf(stderr, "ERROR: BuildVertexInfo bade side!%d!\n", side);
	return NULL;
    }
    return obj;

}

/*
 * ------------------------------------------------------------------------
 *  showMatrix()

Changes to generic/gles2Int.h.

46
47
48
49
50
51
52







53
54
55
56
57
58
59
60
61
62
63
64
65
typedef struct Gles2WidgetImageInfo {
    int version;
    int noGLGetError;
    Tcl_HashTable widgets;
    int numWidgets;
} Gles2WidgetImageInfo;








MODULE_SCOPE unsigned int uiWidth;
MODULE_SCOPE unsigned int uiHeight;

MODULE_SCOPE int GetVertexInfo(Tcl_Interp *interp, Tcl_Obj *obj, Vertex *vertex);
MODULE_SCOPE Tcl_Obj * BuildVertexInfo(Tcl_Interp *interp, int x, int y, int width,
    int height, double red, double green, double blue, double alpha);
MODULE_SCOPE int GetTextureVertexInfo(Tcl_Interp *interp, Tcl_Obj *obj, TextureVertex *vertex);
MODULE_SCOPE int GetRGBAInfo(Tcl_Interp *interp, Tcl_Obj *obj, RgbaInfo *rgba);
MODULE_SCOPE int Gles2_InitFreeType(Tcl_Interp *interp,
        Gles2WidgetImageInfo *infoPtr);
MODULE_SCOPE int Gles2_GetFreeTypeInfo(Tcl_Interp *interp,
        Gles2WidgetImageInfo *infoPtr, const char *fontName, int fontSize,
        RgbaInfo *backgroundrgbaPtr, RgbaInfo *foregroundrgbaPtr, Tcl_Obj *textPtr, Gles2WidgetImage *wgtPtr,







>
>
>
>
>
>
>




|
|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
typedef struct Gles2WidgetImageInfo {
    int version;
    int noGLGetError;
    Tcl_HashTable widgets;
    int numWidgets;
} Gles2WidgetImageInfo;

#define LEFT_SIDE 1
#define TOP_SIDE 2
#define RIGHT_SIDE 4
#define BOTTOM_SIDE 8
#define FRONT_SIDE 16
#define BACK_SIDE 32

MODULE_SCOPE unsigned int uiWidth;
MODULE_SCOPE unsigned int uiHeight;

MODULE_SCOPE int GetVertexInfo(Tcl_Interp *interp, Tcl_Obj *obj, Vertex *vertex);
MODULE_SCOPE Tcl_Obj * BuildVertexInfo(Tcl_Interp *interp, int x, int y, int z, int width,
    int height, int depth, double red, double green, double blue, double alpha, int side);
MODULE_SCOPE int GetTextureVertexInfo(Tcl_Interp *interp, Tcl_Obj *obj, TextureVertex *vertex);
MODULE_SCOPE int GetRGBAInfo(Tcl_Interp *interp, Tcl_Obj *obj, RgbaInfo *rgba);
MODULE_SCOPE int Gles2_InitFreeType(Tcl_Interp *interp,
        Gles2WidgetImageInfo *infoPtr);
MODULE_SCOPE int Gles2_GetFreeTypeInfo(Tcl_Interp *interp,
        Gles2WidgetImageInfo *infoPtr, const char *fontName, int fontSize,
        RgbaInfo *backgroundrgbaPtr, RgbaInfo *foregroundrgbaPtr, Tcl_Obj *textPtr, Gles2WidgetImage *wgtPtr,