GLES2

Check-in [900b282b3b]
Login

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

Overview
Comment:commented out a lot of debug output
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:900b282b3b6e62b8e9eee8f3e7018a625ca262d3
User & Date: arnulf 2013-08-19 14:58:08
Context
2013-08-20
15:29
fixes check-in: 3f269e25b1 user: arnulf tags: trunk
2013-08-19
14:58
commented out a lot of debug output check-in: 900b282b3b user: arnulf tags: trunk
14:07
fixes and new code check-in: 09afec5942 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/gles2Builtin.c.

261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
...
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
...
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
...
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
...
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
...
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
...
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
....
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
....
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
....
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
....
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
....
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
....
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
....
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
....
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
....
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
....
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
....
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
....
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
....
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
....
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
....
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
....
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
....
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
....
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
....
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
....
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203

    fd = fopen(shaderFileStr, "r");
    len = fread(shaderStr, 1, 4096, fd);
    lens[0] = len;
    fclose(fd);
    shaderStr[len] = '\0';
    shaderHandle = GL_CHECK(glCreateShader(shaderType));
fprintf(stderr, "SH!0x%08x!%d!%s!\n", shaderHandle, lens[0], shaderStr);
    GL_CHECK(glShaderSource(shaderHandle, 1, shaderStrings, lens));
	 
    GL_CHECK(glCompileShader(shaderHandle));
    
    glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess);
    if (compileSuccess == GL_FALSE) {
        GLchar messages[256];
................................................................................
}

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) {
................................................................................
    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 {
................................................................................
    double blue;
    double alpha;
    GLfloat gl_red;
    GLfloat gl_green;
    GLfloat gl_blue;
    GLfloat gl_alpha;

    Gles2ShowArgs(0, "Gles_BiClearBufferCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "red green blue alpha");
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[1], &red) != TCL_OK) {
fprintf(stderr, "bad value for red!%s!\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiDrawLineCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "start_vertex end_vertex");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &line_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawLineCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiFillTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiFillTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiDrawTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

num_calls++;
    Gles2ShowArgs(0, "Gles2_BiFillTextureTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiFillTextureTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

num_calls++;
    Gles2ShowArgs(0, "Gles2_BiDrawTextureTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawTextureTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiFillRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiFillRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiDrawRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    int light_objc;
    Tcl_Obj **lightObjv;
    positionBox position_box;
    int borderWidth;
    char *relief;
    shadowColors shadow_colors;

    Gles2ShowArgs(0, "Gles2_BiDrawRectangleBorderCmd", objc, objv);
    if (objc != 5) {
        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;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiFillTextureRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiTextureFillRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles2_BiDrawTextureRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiTextureDrawRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles_BiSetupRenderBufferCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
    GL_CHECK(glGenRenderbuffers(1, &_colorRenderBuffer));
fprintf(stderr, "colorRenderBuffer!%d!\n", _colorRenderBuffer);
    GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer));
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiSetupFrameBufferCmd()
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles_BiSetupFrameBufferCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
    GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer));
    return result;
}
................................................................................
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int use_texture;
    char *texture_flag;

    Gles2ShowArgs(0, "Gles_BiCompileShadersCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "texture_flag");
        return TCL_ERROR;
    }
    texture_flag = Tcl_GetString(objv[1]);
    if (strcmp(texture_flag, "texture") == 0) {
        use_texture = 1;
................................................................................
    int font_size;
    int measure_only;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo backgroundrgba;
    RgbaInfo foregroundrgba;

    Gles2ShowArgs(0, "Gles_BiGetFontInfoCmd", objc, objv);
    if (objc != 9) {
        Tcl_WrongNumArgs(interp, 1, objv, "text font_name font_size backgroundcolor foregroundcolor maxwidth maxheight measureonly");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[3], &font_size) != TCL_OK) {
fprintf(stderr, "bad value for font_size!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
................................................................................
#define NUM_TYPE_ENTRY_BITS 8
    wgtPtr->numTypeItems = NUM_TYPE_ITEMS;
    wgtPtr->numTypeEntryBits = NUM_TYPE_ENTRY_BITS;
    wgtPtr->typeEntryBytes = (wgtPtr->numTypeItems * (wgtPtr->numTypeEntryBits / 8));
    wgtPtr->fontInfo = NULL;
    wgtPtr->fontInfoSize = 0;

fprintf(stderr, "measure_only!%d!\n", measure_only);
    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &backgroundrgba, &foregroundrgba, objv[1], wgtPtr, measure_only) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo ERROR\n");
        return TCL_ERROR;
    }
fprintf(stderr, "width!%d, height!%d! dataSize!%d!\n", wgtPtr->width, wgtPtr->height, wgtPtr->dataSize);
    listObj = Tcl_NewListObj(0, NULL);
    if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(wgtPtr->width)) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo could not append width value %d\n", wgtPtr->width);
        return TCL_ERROR;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(wgtPtr->height)) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo could not append height value %d\n", wgtPtr->height);
................................................................................
0xff, 0xff, 0xff, 0xff, /* A */ 0xff, 0xff, 0xff, 0xff, /* B */
0xff, 0xff, 0xff, 0xff, /* C */ 0xff, 0xff, 0xff, 0xff, /* D */
0x00, 0x00, 0x00, 0xff, /* E */ 0x00, 0x00, 0x00, 0xff, /* F */

};
#endif

    Gles2ShowArgs(0, "Gles_BiMakeTextTextureCmd", objc, objv);
    if (objc != 8) {
        Tcl_WrongNumArgs(interp, 1, objv, "text font_name font_size backgroundcolor foregroundcolor maxwidth maxheight");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[3], &font_size) != TCL_OK) {
fprintf(stderr, "bad value for font_size!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
................................................................................
    wgtPtr->fontInfoSize = 0;

    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &backgroundrgba, &foregroundrgba, objv[1], wgtPtr, measure_only) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo ERROR\n");
        return TCL_ERROR;
    }
fprintf(stderr, "width!%d, height!%d! dataSize!%d!\n", wgtPtr->width, wgtPtr->height, wgtPtr->dataSize);
#ifdef NOTDEF
for (i = 0; i < wgtPtr->dataSize; i++) {
    if (i % 14 == 0) {
        fprintf(stderr, "\n");
    }
    fprintf(stderr, " 0x%02x", ((unsigned char *)wgtPtr->data)[i]);
}
................................................................................
    GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); 
	     
#ifndef TESTING
    GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wgtPtr->width, wgtPtr->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wgtPtr->data));
#else
    GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void *)buf));
#endif
fprintf(stderr, "texName!%d!\n", texName);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiPixel2CoordCmd()
 *
................................................................................
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int value = 0;
    int useWidth = 0;
    GLfloat glValue;

    Gles2ShowArgs(0, "Gles_BiPixel2CoordCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "value useWidth");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[1], &value) != TCL_OK) {
fprintf(stderr, "bad value for value!%s!\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
................................................................................
 */
int Gles2_BiValue2PixelCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    Gles2ShowArgs(0, "Gles_BiValue2PixelCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "value");
        return TCL_ERROR;
    }
    return Value2Pixel(interp, objv[1]);
}

................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;

    Gles2ShowArgs(0, "Gles_BiColorValue2RGBACmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "value");
        return TCL_ERROR;
    }
    obj = ColorValue2RGBA(interp, objv[1]);
fprintf(stderr, "OBJ!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;

    Gles2ShowArgs(0, "Gles_BiGetElementPositionsCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "box");
        return TCL_ERROR;
    }
    obj = GetElementPositions(interp, objv[1]);
fprintf(stderr, "OBJ!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;
    int diameter;

    Gles2ShowArgs(0, "Gles_BiGetDiamondPositionsCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "box diameter");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[2], &diameter) != TCL_OK) {
fprintf(stderr, "bad value for diameter!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    obj = GetDiamondPositions(interp, objv[1], diameter);
fprintf(stderr, "OBJ!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;

    Gles2ShowArgs(0, "Gles_BiGetShadowsCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "backgroundColor");
        return TCL_ERROR;
    }
    obj = GetShadows(interp, objv[1]);
fprintf(stderr, "SHADOWS!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(0, "Gles_BiSwapShadersCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
fprintf(stderr, "swapshaders not yet implemented!!\n");
    return result;
}








|







 







|











|


|

|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|







 







|





|







 







|







 







|







 







|







 







|





|







 







|







 







|







 







|







 







|







 







|







 







|





<







 







|





<







 







|









<







 







|





|







 







|








261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
...
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
...
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
...
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
...
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
...
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
...
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
...
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
....
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
....
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
....
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
....
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
....
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
....
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
....
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
....
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
....
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
....
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
....
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
....
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
....
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
....
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
....
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
....
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056

2057
2058
2059
2060
2061
2062
2063
....
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090

2091
2092
2093
2094
2095
2096
2097
....
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129

2130
2131
2132
2133
2134
2135
2136
....
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
....
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200

    fd = fopen(shaderFileStr, "r");
    len = fread(shaderStr, 1, 4096, fd);
    lens[0] = len;
    fclose(fd);
    shaderStr[len] = '\0';
    shaderHandle = GL_CHECK(glCreateShader(shaderType));
//fprintf(stderr, "SH!0x%08x!%d!%s!\n", shaderHandle, lens[0], shaderStr);
    GL_CHECK(glShaderSource(shaderHandle, 1, shaderStrings, lens));
	 
    GL_CHECK(glCompileShader(shaderHandle));
    
    glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &compileSuccess);
    if (compileSuccess == GL_FALSE) {
        GLchar messages[256];
................................................................................
}

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) {
................................................................................
    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 {
................................................................................
    double blue;
    double alpha;
    GLfloat gl_red;
    GLfloat gl_green;
    GLfloat gl_blue;
    GLfloat gl_alpha;

    Gles2ShowArgs(1, "Gles_BiClearBufferCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "red green blue alpha");
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[1], &red) != TCL_OK) {
fprintf(stderr, "bad value for red!%s!\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiDrawLineCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "start_vertex end_vertex");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &line_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawLineCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiFillTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiFillTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiDrawTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

num_calls++;
    Gles2ShowArgs(1, "Gles2_BiFillTextureTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiFillTextureTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

num_calls++;
    Gles2ShowArgs(1, "Gles2_BiDrawTextureTriangleCmd", objc, objv);
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_triangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawTextureTriangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiFillRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiFillRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiDrawRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetVertexInfo(interp, objv[1], &rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiDrawRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    int light_objc;
    Tcl_Obj **lightObjv;
    positionBox position_box;
    int borderWidth;
    char *relief;
    shadowColors shadow_colors;

    Gles2ShowArgs(1, "Gles2_BiDrawRectangleBorderCmd", objc, objv);
    if (objc != 5) {
        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;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiFillTextureRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiTextureFillRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles2_BiDrawTextureRectangleCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "vertex1 vertex2 vertex3 vertex4");
        return TCL_ERROR;
    }
    if (GetTextureVertexInfo(interp, objv[1], &texture_rectangle_vertices[0]) != TCL_OK) {
fprintf(stderr, "Gles2_BiTextureDrawRectangleCmd1 ERROR\n");
        return TCL_ERROR;
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles_BiSetupRenderBufferCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
    GL_CHECK(glGenRenderbuffers(1, &_colorRenderBuffer));
//fprintf(stderr, "colorRenderBuffer!%d!\n", _colorRenderBuffer);
    GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, _colorRenderBuffer));
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiSetupFrameBufferCmd()
................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles_BiSetupFrameBufferCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
    GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, framebuffer));
    return result;
}
................................................................................
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int use_texture;
    char *texture_flag;

    Gles2ShowArgs(1, "Gles_BiCompileShadersCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "texture_flag");
        return TCL_ERROR;
    }
    texture_flag = Tcl_GetString(objv[1]);
    if (strcmp(texture_flag, "texture") == 0) {
        use_texture = 1;
................................................................................
    int font_size;
    int measure_only;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo backgroundrgba;
    RgbaInfo foregroundrgba;

    Gles2ShowArgs(1, "Gles_BiGetFontInfoCmd", objc, objv);
    if (objc != 9) {
        Tcl_WrongNumArgs(interp, 1, objv, "text font_name font_size backgroundcolor foregroundcolor maxwidth maxheight measureonly");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[3], &font_size) != TCL_OK) {
fprintf(stderr, "bad value for font_size!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
................................................................................
#define NUM_TYPE_ENTRY_BITS 8
    wgtPtr->numTypeItems = NUM_TYPE_ITEMS;
    wgtPtr->numTypeEntryBits = NUM_TYPE_ENTRY_BITS;
    wgtPtr->typeEntryBytes = (wgtPtr->numTypeItems * (wgtPtr->numTypeEntryBits / 8));
    wgtPtr->fontInfo = NULL;
    wgtPtr->fontInfoSize = 0;

//fprintf(stderr, "measure_only!%d!\n", measure_only);
    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &backgroundrgba, &foregroundrgba, objv[1], wgtPtr, measure_only) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo ERROR\n");
        return TCL_ERROR;
    }
//fprintf(stderr, "width!%d, height!%d! dataSize!%d!\n", wgtPtr->width, wgtPtr->height, wgtPtr->dataSize);
    listObj = Tcl_NewListObj(0, NULL);
    if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(wgtPtr->width)) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo could not append width value %d\n", wgtPtr->width);
        return TCL_ERROR;
    }
    if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(wgtPtr->height)) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo could not append height value %d\n", wgtPtr->height);
................................................................................
0xff, 0xff, 0xff, 0xff, /* A */ 0xff, 0xff, 0xff, 0xff, /* B */
0xff, 0xff, 0xff, 0xff, /* C */ 0xff, 0xff, 0xff, 0xff, /* D */
0x00, 0x00, 0x00, 0xff, /* E */ 0x00, 0x00, 0x00, 0xff, /* F */

};
#endif

    Gles2ShowArgs(1, "Gles_BiMakeTextTextureCmd", objc, objv);
    if (objc != 8) {
        Tcl_WrongNumArgs(interp, 1, objv, "text font_name font_size backgroundcolor foregroundcolor maxwidth maxheight");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[3], &font_size) != TCL_OK) {
fprintf(stderr, "bad value for font_size!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
................................................................................
    wgtPtr->fontInfoSize = 0;

    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &backgroundrgba, &foregroundrgba, objv[1], wgtPtr, measure_only) != TCL_OK) {
fprintf(stderr, "Gles2_GetFreeTypeInfo ERROR\n");
        return TCL_ERROR;
    }
//fprintf(stderr, "width!%d, height!%d! dataSize!%d!\n", wgtPtr->width, wgtPtr->height, wgtPtr->dataSize);
#ifdef NOTDEF
for (i = 0; i < wgtPtr->dataSize; i++) {
    if (i % 14 == 0) {
        fprintf(stderr, "\n");
    }
    fprintf(stderr, " 0x%02x", ((unsigned char *)wgtPtr->data)[i]);
}
................................................................................
    GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); 
	     
#ifndef TESTING
    GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wgtPtr->width, wgtPtr->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wgtPtr->data));
#else
    GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void *)buf));
#endif
//fprintf(stderr, "texName!%d!\n", texName);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiPixel2CoordCmd()
 *
................................................................................
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int value = 0;
    int useWidth = 0;
    GLfloat glValue;

    Gles2ShowArgs(1, "Gles_BiPixel2CoordCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "value useWidth");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[1], &value) != TCL_OK) {
fprintf(stderr, "bad value for value!%s!\n", Tcl_GetString(objv[1]));
        return TCL_ERROR;
................................................................................
 */
int Gles2_BiValue2PixelCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    Gles2ShowArgs(1, "Gles_BiValue2PixelCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "value");
        return TCL_ERROR;
    }
    return Value2Pixel(interp, objv[1]);
}

................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;

    Gles2ShowArgs(1, "Gles_BiColorValue2RGBACmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "value");
        return TCL_ERROR;
    }
    obj = ColorValue2RGBA(interp, objv[1]);

    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;

    Gles2ShowArgs(1, "Gles_BiGetElementPositionsCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "box");
        return TCL_ERROR;
    }
    obj = GetElementPositions(interp, objv[1]);

    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;
    int diameter;

    Gles2ShowArgs(1, "Gles_BiGetDiamondPositionsCmd", objc, objv);
    if (objc != 3) {
        Tcl_WrongNumArgs(interp, 1, objv, "box diameter");
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[2], &diameter) != TCL_OK) {
fprintf(stderr, "bad value for diameter!%s!\n", Tcl_GetString(objv[2]));
        return TCL_ERROR;
    }
    obj = GetDiamondPositions(interp, objv[1], diameter);

    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    Tcl_Obj *obj;

    Gles2ShowArgs(1, "Gles_BiGetShadowsCmd", objc, objv);
    if (objc != 2) {
        Tcl_WrongNumArgs(interp, 1, objv, "backgroundColor");
        return TCL_ERROR;
    }
    obj = GetShadows(interp, objv[1]);
//fprintf(stderr, "SHADOWS!%s!\n", Tcl_GetString(obj));
    if (obj == NULL) {
        return TCL_ERROR;
    }
    Tcl_SetObjResult(interp, obj);
    return result;
}

................................................................................
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;

    Gles2ShowArgs(1, "Gles_BiSwapShadersCmd", objc, objv);
    if (objc != 1) {
        Tcl_WrongNumArgs(interp, 1, objv, "");
        return TCL_ERROR;
    }
fprintf(stderr, "swapshaders not yet implemented!!\n");
    return result;
}

Changes to generic/gles2FreeType.c.

229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
...
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
        } else {
	    CachedFont.fontNamePtr = Tcl_NewStringObj("", 0);
	}
        Tcl_SetStringObj(CachedFont.fontNamePtr, fontName, -1);
	CachedFont.fontSize = fontSize;
fontName = "/home/arnulf/SOURCES/GLES2/library/Vera.ttf";
//fontName = "/home/arnulf/SOURCES/TCL/OLD/itcl1/itk/ntk/library/Vera.ttf";
fprintf(stderr, "FONT name!%s!%d!\n", fontName, fontSize);
	result = FT_New_Face(library, fontName, 0, &CachedFont.face);
	if (result == FT_Err_Unknown_File_Format) {
	    Tcl_SetResult(interp, "invalid font file format", TCL_STATIC);
	    return TCL_ERROR;
	}
	if (result != 0) {
	    Tcl_SetResult(interp, "unable to open or read font file",
................................................................................
    }
    /* FIX ME !! need to eventually free data !! */
    wgtPtr->width = 1;
    wgtPtr->height = 1;
    if (LoadString(interp, wgtPtr, CachedFont.face, measureOnly) != TCL_OK) {
        return TCL_ERROR;
    }
fprintf(stderr, "rgba background r!%d!g!%d!b!%d!@:%d!\n", backgroundrgbaPtr->Color[0], backgroundrgbaPtr->Color[1], backgroundrgbaPtr->Color[2], backgroundrgbaPtr->Color[3]);
fprintf(stderr, "rgba foreground r!%d!g!%d!b!%d!@:%d!\n", foregroundrgbaPtr->Color[0], foregroundrgbaPtr->Color[1], foregroundrgbaPtr->Color[2], foregroundrgbaPtr->Color[3]);
fprintf(stderr, "w!%d!h!%d!o!%d!\n", wgtPtr->width, wgtPtr->height, measureOnly);
    if (!measureOnly) {
fprintf(stderr, "maxw!%d!maxh!%d!\n", wgtPtr->maxWidth, wgtPtr->maxHeight);
        bottom = 0;
        for (i=0;i<wgtPtr->unitextlen;++i) {
            if (wgtPtr->fontInfo[i].bottom < bottom) {
                bottom = wgtPtr->fontInfo[i].bottom;
            }
        }
        wgtPtr->dataSize = wgtPtr->width * wgtPtr->height *
                /*RGBA*/wgtPtr->typeEntryBytes;
        bitmap = (GLubyte *)ckalloc (wgtPtr->dataSize * sizeof(GLubyte));
//        memset (bitmap, 0x00, wgtPtr->dataSize);
fprintf(stderr, "dS!%d!%d!\n", wgtPtr->dataSize, wgtPtr->typeEntryBytes);
        wgtPtr->data = bitmap;
cp = wgtPtr->data;
for (j = 0; j < wgtPtr->dataSize; j++) {
//    fprintf(stderr, "j!%d!\n", j);
    if (j % 4 == 0) {
      *cp = backgroundrgbaPtr->Color[1];
    }
................................................................................
      *cp = backgroundrgbaPtr->Color[4];
    }
}
        numRgbaBytes = wgtPtr->typeEntryBytes;
        int destx;
        destx = 0;
        for (i= 0;i<wgtPtr->unitextlen;++i) {
fprintf(stderr, "handle ch!%c!\n", wgtPtr->unitext[i]);
	    GLubyte *dp;
	    GLubyte ch;
	    int desty;
	    int ty;
	    int tx;
	    int x;
	    int y;







|







 







|
|
|

|










|







 







|







229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
...
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
...
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
        } else {
	    CachedFont.fontNamePtr = Tcl_NewStringObj("", 0);
	}
        Tcl_SetStringObj(CachedFont.fontNamePtr, fontName, -1);
	CachedFont.fontSize = fontSize;
fontName = "/home/arnulf/SOURCES/GLES2/library/Vera.ttf";
//fontName = "/home/arnulf/SOURCES/TCL/OLD/itcl1/itk/ntk/library/Vera.ttf";
//fprintf(stderr, "FONT name!%s!%d!\n", fontName, fontSize);
	result = FT_New_Face(library, fontName, 0, &CachedFont.face);
	if (result == FT_Err_Unknown_File_Format) {
	    Tcl_SetResult(interp, "invalid font file format", TCL_STATIC);
	    return TCL_ERROR;
	}
	if (result != 0) {
	    Tcl_SetResult(interp, "unable to open or read font file",
................................................................................
    }
    /* FIX ME !! need to eventually free data !! */
    wgtPtr->width = 1;
    wgtPtr->height = 1;
    if (LoadString(interp, wgtPtr, CachedFont.face, measureOnly) != TCL_OK) {
        return TCL_ERROR;
    }
//fprintf(stderr, "rgba background r!%d!g!%d!b!%d!@:%d!\n", backgroundrgbaPtr->Color[0], backgroundrgbaPtr->Color[1], backgroundrgbaPtr->Color[2], backgroundrgbaPtr->Color[3]);
//fprintf(stderr, "rgba foreground r!%d!g!%d!b!%d!@:%d!\n", foregroundrgbaPtr->Color[0], foregroundrgbaPtr->Color[1], foregroundrgbaPtr->Color[2], foregroundrgbaPtr->Color[3]);
//fprintf(stderr, "w!%d!h!%d!o!%d!\n", wgtPtr->width, wgtPtr->height, measureOnly);
    if (!measureOnly) {
//fprintf(stderr, "maxw!%d!maxh!%d!\n", wgtPtr->maxWidth, wgtPtr->maxHeight);
        bottom = 0;
        for (i=0;i<wgtPtr->unitextlen;++i) {
            if (wgtPtr->fontInfo[i].bottom < bottom) {
                bottom = wgtPtr->fontInfo[i].bottom;
            }
        }
        wgtPtr->dataSize = wgtPtr->width * wgtPtr->height *
                /*RGBA*/wgtPtr->typeEntryBytes;
        bitmap = (GLubyte *)ckalloc (wgtPtr->dataSize * sizeof(GLubyte));
//        memset (bitmap, 0x00, wgtPtr->dataSize);
//fprintf(stderr, "dS!%d!%d!\n", wgtPtr->dataSize, wgtPtr->typeEntryBytes);
        wgtPtr->data = bitmap;
cp = wgtPtr->data;
for (j = 0; j < wgtPtr->dataSize; j++) {
//    fprintf(stderr, "j!%d!\n", j);
    if (j % 4 == 0) {
      *cp = backgroundrgbaPtr->Color[1];
    }
................................................................................
      *cp = backgroundrgbaPtr->Color[4];
    }
}
        numRgbaBytes = wgtPtr->typeEntryBytes;
        int destx;
        destx = 0;
        for (i= 0;i<wgtPtr->unitextlen;++i) {
//fprintf(stderr, "handle ch!%c!\n", wgtPtr->unitext[i]);
	    GLubyte *dp;
	    GLubyte ch;
	    int desty;
	    int ty;
	    int tx;
	    int x;
	    int y;

Changes to generic/gles2Helpers.c.

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
...
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
...
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
    vertex->Color[2] = dbl;
    /* alpha */
    if (Tcl_GetDoubleFromObj(interp, color_objv[3], &dbl) != TCL_OK) {
fprintf(stderr, "bad value for aplpha!%s!\n", Tcl_GetString(color_objv[3]));
        return TCL_ERROR;
    }
    vertex->Color[3] = dbl;
fprintf(stderr, "x:%f!y:%f!z:%f!r:%f!g:%f!b:%f!@:%f!\n", vertex->Position[0], vertex->Position[1], vertex->Position[2], vertex->Color[0], vertex->Color[1], vertex->Color[2], vertex->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  GetTextureVertexInfo()
 *
................................................................................
    vertex->Color[2] = dbl;
    /* alpha */
    if (Tcl_GetDoubleFromObj(interp, color_objv[3], &dbl) != TCL_OK) {
fprintf(stderr, "bad value for aplpha!%s!\n", Tcl_GetString(color_objv[3]));
        return TCL_ERROR;
    }
    vertex->Color[3] = dbl;
fprintf(stderr, "x:%f!y:%f!z:%f!r:%f!g:%f!b:%f!@:%f!\n", vertex->Position[0], vertex->Position[1], vertex->Position[2], vertex->Color[0], vertex->Color[1], vertex->Color[2], vertex->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  GetRGBAInfo()
 *
................................................................................
    rgba->Color[2] = (GLubyte)(dbl * 255);
    /* alpha */
    if (Tcl_GetDoubleFromObj(interp, color_objv[3], &dbl) != TCL_OK) {
fprintf(stderr, "bad value for aplpha!%s!\n", Tcl_GetString(color_objv[3]));
        return TCL_ERROR;
    }
    rgba->Color[3] = (GLubyte)(dbl * 255);
fprintf(stderr, "r:%d!g:%d!b:%d!@:%d!\n", rgba->Color[0], rgba->Color[1], rgba->Color[2], rgba->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  Pixel2Coord()
 *
................................................................................
    int x;
    int y;
    int width;
    int height;
    GLfloat f_x;
    GLfloat f_y;
    GLfloat f_z;
    GLfloat f_width;
    GLfloat f_height;
    GLfloat radius;
    GLfloat w_radius;
    GLfloat h_radius;

    radius = diameter / 2.0;
    w_radius = Pixel2Coord(interp, radius, 1);
    h_radius = Pixel2Coord(interp, radius, 0);
................................................................................
    }
    f_y = Pixel2Coord(interp, y, 0);
    /* width */
    if (Tcl_GetIntFromObj(interp, pos_objv[2], &width) != TCL_OK) {
fprintf(stderr, "bad value for width!%s!\n", Tcl_GetString(pos_objv[2]));
        return NULL;
    }
    f_width = Pixel2Coord(interp, width, 1);
fprintf(stderr, "RADIUS!%f!%f!%f!\n", w_radius, h_radius, f_width);
    /* height */
    if (Tcl_GetIntFromObj(interp, pos_objv[3], &height) != TCL_OK) {
fprintf(stderr, "bad value for height!%s!\n", Tcl_GetString(pos_objv[3]));
        return NULL;
    }
    f_height = Pixel2Coord(interp, height, 0);
    listObj = Tcl_NewListObj(0, NULL); /* the return obj */

    /* pos1 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_x)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append x value: %s\n", Tcl_GetString(obj));
        return NULL;







|







 







|







 







|







 







|
|







 







|
<





|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
...
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
...
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
...
718
719
720
721
722
723
724
725

726
727
728
729
730
731
732
733
734
735
736
737
738
    vertex->Color[2] = dbl;
    /* alpha */
    if (Tcl_GetDoubleFromObj(interp, color_objv[3], &dbl) != TCL_OK) {
fprintf(stderr, "bad value for aplpha!%s!\n", Tcl_GetString(color_objv[3]));
        return TCL_ERROR;
    }
    vertex->Color[3] = dbl;
//fprintf(stderr, "x:%f!y:%f!z:%f!r:%f!g:%f!b:%f!@:%f!\n", vertex->Position[0], vertex->Position[1], vertex->Position[2], vertex->Color[0], vertex->Color[1], vertex->Color[2], vertex->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  GetTextureVertexInfo()
 *
................................................................................
    vertex->Color[2] = dbl;
    /* alpha */
    if (Tcl_GetDoubleFromObj(interp, color_objv[3], &dbl) != TCL_OK) {
fprintf(stderr, "bad value for aplpha!%s!\n", Tcl_GetString(color_objv[3]));
        return TCL_ERROR;
    }
    vertex->Color[3] = dbl;
//fprintf(stderr, "x:%f!y:%f!z:%f!r:%f!g:%f!b:%f!@:%f!\n", vertex->Position[0], vertex->Position[1], vertex->Position[2], vertex->Color[0], vertex->Color[1], vertex->Color[2], vertex->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  GetRGBAInfo()
 *
................................................................................
    rgba->Color[2] = (GLubyte)(dbl * 255);
    /* alpha */
    if (Tcl_GetDoubleFromObj(interp, color_objv[3], &dbl) != TCL_OK) {
fprintf(stderr, "bad value for aplpha!%s!\n", Tcl_GetString(color_objv[3]));
        return TCL_ERROR;
    }
    rgba->Color[3] = (GLubyte)(dbl * 255);
//fprintf(stderr, "r:%d!g:%d!b:%d!@:%d!\n", rgba->Color[0], rgba->Color[1], rgba->Color[2], rgba->Color[3]);
    return TCL_OK;
}

/*
 * ------------------------------------------------------------------------
 *  Pixel2Coord()
 *
................................................................................
    int x;
    int y;
    int width;
    int height;
    GLfloat f_x;
    GLfloat f_y;
    GLfloat f_z;
//    GLfloat f_width;
//    GLfloat f_height;
    GLfloat radius;
    GLfloat w_radius;
    GLfloat h_radius;

    radius = diameter / 2.0;
    w_radius = Pixel2Coord(interp, radius, 1);
    h_radius = Pixel2Coord(interp, radius, 0);
................................................................................
    }
    f_y = Pixel2Coord(interp, y, 0);
    /* width */
    if (Tcl_GetIntFromObj(interp, pos_objv[2], &width) != TCL_OK) {
fprintf(stderr, "bad value for width!%s!\n", Tcl_GetString(pos_objv[2]));
        return NULL;
    }
//    f_width = Pixel2Coord(interp, width, 1);

    /* height */
    if (Tcl_GetIntFromObj(interp, pos_objv[3], &height) != TCL_OK) {
fprintf(stderr, "bad value for height!%s!\n", Tcl_GetString(pos_objv[3]));
        return NULL;
    }
//    f_height = Pixel2Coord(interp, height, 0);
    listObj = Tcl_NewListObj(0, NULL); /* the return obj */

    /* pos1 */
    list1Obj = Tcl_NewListObj(0, NULL); /* the position obj */
    if (Tcl_ListObjAppendElement(interp, list1Obj, Tcl_NewDoubleObj(-1.0 + f_x)) != TCL_OK) {
fprintf(stderr, "GetDiamondPositions could not append x value: %s\n", Tcl_GetString(obj));
        return NULL;