GLES2

Check-in [09afec5942]
Login

Check-in [09afec5942]

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

Overview
Comment:fixes and new code
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 09afec59425e7d163282a2775f02f51f1c2e6d53
User & Date: arnulf 2013-08-19 14:07:48.433
Context
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
2013-08-18
21:50
fixes check-in: 21185d0470 user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/gles2Builtin.c.
676
677
678
679
680
681
682





683
684
685
686
687
688
689
690
691
692
fprintf(stderr, "bad value for blue!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[4], &alpha) != TCL_OK) {
fprintf(stderr, "bad value for alpha!%s!\n", Tcl_GetString(objv[4]));
        return TCL_ERROR;
    }





 GL_CHECK(glEnable(GL_BLEND));
// GL_CHECK(glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR));
 GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_DST_COLOR));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ZERO));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); // OK?
    setupVBOs0();
    gl_red = (GLfloat)(red/255.0);
    gl_green = (GLfloat)(green/255.0);
    gl_blue = (GLfloat)(blue/255.0);
    gl_alpha = (GLfloat)(alpha/255.0);







>
>
>
>
>


|







676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
fprintf(stderr, "bad value for blue!%s!\n", Tcl_GetString(objv[3]));
        return TCL_ERROR;
    }
    if (Tcl_GetDoubleFromObj(interp, objv[4], &alpha) != TCL_OK) {
fprintf(stderr, "bad value for alpha!%s!\n", Tcl_GetString(objv[4]));
        return TCL_ERROR;
    }
// GL_CHECK(glBlendFunc(GL_SRC_ALPHA, GL_ONE));
 GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_DST_ALPHA));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_DST_COLOR));
 GL_CHECK(glEnable(GL_BLEND));
// GL_CHECK(glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR));
//( GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_DST_COLOR));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ZERO));
// GL_CHECK(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); // OK?
    setupVBOs0();
    gl_red = (GLfloat)(red/255.0);
    gl_green = (GLfloat)(green/255.0);
    gl_blue = (GLfloat)(blue/255.0);
    gl_alpha = (GLfloat)(alpha/255.0);
1382
1383
1384
1385
1386
1387
1388









1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410

    rectangle_indices[0] = 0;
    rectangle_indices[1] = 1;
    rectangle_indices[2] = 2;
    rectangle_indices[3] = 2;
    rectangle_indices[4] = 3;
    rectangle_indices[5] = 0;










    GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(TextureVertex), 0));
    GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 3)));

    handleMatrices(0, 0);

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_rectangle_vertices), &texture_rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rectangle_indices), &rectangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));
    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texName));
    GL_CHECK(glUniform1i(_textureUniform, 0));

    GL_CHECK(glDrawElements(GL_TRIANGLES, sizeof(rectangle_indices)/sizeof(rectangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
}

/*







>
>
>
>
>
>
>
>
>





<
<
<
<
<


<
<
<







1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407





1408
1409



1410
1411
1412
1413
1414
1415
1416

    rectangle_indices[0] = 0;
    rectangle_indices[1] = 1;
    rectangle_indices[2] = 2;
    rectangle_indices[3] = 2;
    rectangle_indices[4] = 3;
    rectangle_indices[5] = 0;

    GL_CHECK(glBufferData(GL_ARRAY_BUFFER, sizeof(texture_rectangle_vertices), &texture_rectangle_vertices, GL_STATIC_DRAW));
    GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(rectangle_indices), &rectangle_indices, GL_STATIC_DRAW));

    GL_CHECK(glActiveTexture(GL_TEXTURE0)); 
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texName));
    GL_CHECK(glUniform1i(_textureUniform, 0));

    handleMatrices(0, 0);

    GL_CHECK(glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(TextureVertex), 0));
    GL_CHECK(glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 3)));






    GL_CHECK(glVertexAttribPointer(_texCoordSlot, 2, GL_FLOAT, GL_FALSE, 
		        sizeof(TextureVertex), (GLvoid*) (sizeof(float) * 7)));




    GL_CHECK(glDrawElements(GL_TRIANGLES, sizeof(rectangle_indices)/sizeof(rectangle_indices[0]), GL_UNSIGNED_BYTE, 0));

    return result;
}

/*
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622

1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636




1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
 * ------------------------------------------------------------------------
 *  Gles2_BiGetFontInfoCmd()
 *
 *  Invoked to handle the "getfontinfo" command
 *  Handles the
 *  following syntax:
 *
 *    getfontinfo text font_name font_size color maxwidth maxheight measureonly
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiGetFontInfoCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
	Tcl_Obj *listObj;
    int result = TCL_OK;
    int font_size;
    int measure_only;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo rgba;


    Gles2ShowArgs(0, "Gles_BiGetFontInfoCmd", objc, objv);
    if (objc != 8) {
        Tcl_WrongNumArgs(interp, 1, objv, "text font_name font_size color 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;
    }
    if (GetRGBAInfo(interp, objv[4], &rgba) != TCL_OK) {
fprintf(stderr, "bad value for rgba!%s!\n", Tcl_GetString(objv[4]));
        return TCL_ERROR;
    }




    if (Tcl_GetIntFromObj(interp, objv[5], &wgt.maxWidth) != TCL_OK) {
fprintf(stderr, "bad value for maxwidth!%s!\n", Tcl_GetString(objv[5]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[6], &wgt.maxHeight) != TCL_OK) {
fprintf(stderr, "bad value for maxheight!%s!\n", Tcl_GetString(objv[6]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[7], &measure_only) != TCL_OK) {
fprintf(stderr, "bad value for measureonly!%s!\n", Tcl_GetString(objv[5]));
        return TCL_ERROR;
    }
    wgtPtr = &wgt;
    memset(wgtPtr, 0, sizeof(wgt));
#define NUM_TYPE_ITEMS 4
#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,
        &rgba, 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);







|















|
>


|
|






|
|


>
>
>
>
|
|


|
|


|
|














|







1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
 * ------------------------------------------------------------------------
 *  Gles2_BiGetFontInfoCmd()
 *
 *  Invoked to handle the "getfontinfo" command
 *  Handles the
 *  following syntax:
 *
 *    getfontinfo text font_name font_size backgroundcolor foregroundcolor maxwidth maxheight measureonly
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiGetFontInfoCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
	Tcl_Obj *listObj;
    int result = TCL_OK;
    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;
    }
    if (GetRGBAInfo(interp, objv[4], &backgroundrgba) != TCL_OK) {
fprintf(stderr, "bad value for backgroundrgba!%s!\n", Tcl_GetString(objv[4]));
        return TCL_ERROR;
    }
    if (GetRGBAInfo(interp, objv[5], &foregroundrgba) != TCL_OK) {
fprintf(stderr, "bad value for foregroundrgba!%s!\n", Tcl_GetString(objv[5]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[6], &wgt.maxWidth) != TCL_OK) {
fprintf(stderr, "bad value for maxwidth!%s!\n", Tcl_GetString(objv[6]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[7], &wgt.maxHeight) != TCL_OK) {
fprintf(stderr, "bad value for maxheight!%s!\n", Tcl_GetString(objv[7]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[8], &measure_only) != TCL_OK) {
fprintf(stderr, "bad value for measureonly!%s!\n", Tcl_GetString(objv[8]));
        return TCL_ERROR;
    }
    wgtPtr = &wgt;
    memset(wgtPtr, 0, sizeof(wgt));
#define NUM_TYPE_ITEMS 4
#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);
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
1711
1712
1713
1714












1715
1716
1717
1718
1719
1720
1721
1722
1723


1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741

1742
1743
1744
1745
1746

1747



1748
1749
1750
1751
1752
1753
1754
 * ------------------------------------------------------------------------
 *  Gles2_BiMakeTextTextureCmd()
 *
 *  Invoked to handle the "maketexttexture" command
 *  Handles the
 *  following syntax:
 *
 *    maketexttexture font_name
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiMakeTextTextureCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int font_size;


    int measure_only = 0;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo rgba;




















































































































































































    Gles2ShowArgs(0, "Gles_BiMakeTextTextureCmd", objc, objv);
    if (objc != 5) {
        Tcl_WrongNumArgs(interp, 1, objv, "text font_name font_size color");
        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;
    }
    if (GetRGBAInfo(interp, objv[4], &rgba) != TCL_OK) {
fprintf(stderr, "bad value for rgba!%s!\n", Tcl_GetString(objv[4]));












        return TCL_ERROR;
    }
    wgtPtr = &wgt;
    memset(wgtPtr, 0, sizeof(wgt));
#define NUM_TYPE_ITEMS 4
#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;

    if (Gles2_GetFreeTypeInfo(interp, NULL, Tcl_GetString(objv[2]), font_size,
        &rgba, 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]);
}
fprintf(stderr, "\n");
#endif

    GL_CHECK(glGenTextures(1, &texName));
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texName));
	 
    GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)); 
	     

    GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wgtPtr->width, wgtPtr->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, wgtPtr->data));



fprintf(stderr, "texName!%d!\n", texName);
    return result;
}

/*
 * ------------------------------------------------------------------------
 *  Gles2_BiPixel2CoordCmd()







|











>
>



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


|
|






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









>
>




|













>





>

>
>
>







1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
 * ------------------------------------------------------------------------
 *  Gles2_BiMakeTextTextureCmd()
 *
 *  Invoked to handle the "maketexttexture" command
 *  Handles the
 *  following syntax:
 *
 *    maketexttexture text font_name font_size backgroundcolor foregroundcolor maxwidth maxheight
 *
 * ------------------------------------------------------------------------
 */
int Gles2_BiMakeTextTextureCmd(
    ClientData dummy,        /* not used */
    Tcl_Interp *interp,      /* current interpreter */
    int objc,                /* number of arguments */
    Tcl_Obj *const objv[])   /* argument objects */
{
    int result = TCL_OK;
    int font_size;
    int maxWidth;
    int maxHeight;
    int measure_only = 0;
    Gles2WidgetImage wgt;
    Gles2WidgetImage *wgtPtr;
    RgbaInfo backgroundrgba;
    RgbaInfo foregroundrgba;
#ifdef TESTING
char buf[1024] = {
/* 0 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */

/* 1 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 2 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 3 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 4 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 5 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 6 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 7 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 8 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* 9 */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* A */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* B */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* C */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* D */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* E */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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 */


/* F */
0xff, 0xff, 0xff, 0xff, /* 0 */ 0xff, 0xff, 0xff, 0xff, /* 1 */
0xff, 0xff, 0xff, 0xff, /* 2 */ 0xff, 0xff, 0xff, 0xff, /* 3 */
0xff, 0xff, 0xff, 0xff, /* 4 */ 0xff, 0xff, 0xff, 0xff, /* 5 */
0xff, 0xff, 0xff, 0xff, /* 6 */ 0xff, 0xff, 0xff, 0xff, /* 7 */
0xff, 0xff, 0xff, 0xff, /* 8 */ 0xff, 0xff, 0xff, 0xff, /* 9 */
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;
    }
    if (GetRGBAInfo(interp, objv[4], &backgroundrgba) != TCL_OK) {
fprintf(stderr, "bad value for backgroundrgba!%s!\n", Tcl_GetString(objv[4]));
        return TCL_ERROR;
    }
    if (GetRGBAInfo(interp, objv[5], &foregroundrgba) != TCL_OK) {
fprintf(stderr, "bad value for foregroundrgba!%s!\n", Tcl_GetString(objv[5]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[6], &maxWidth) != TCL_OK) {
fprintf(stderr, "bad value for maxWidth!%s!\n", Tcl_GetString(objv[6]));
        return TCL_ERROR;
    }
    if (Tcl_GetIntFromObj(interp, objv[7], &maxHeight) != TCL_OK) {
fprintf(stderr, "bad value for maxHeight!%s!\n", Tcl_GetString(objv[7]));
        return TCL_ERROR;
    }
    wgtPtr = &wgt;
    memset(wgtPtr, 0, sizeof(wgt));
#define NUM_TYPE_ITEMS 4
#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->maxWidth = maxWidth;
    wgtPtr->maxHeight = maxHeight;
    wgtPtr->fontInfo = NULL;
    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]);
}
fprintf(stderr, "\n");
#endif
    GL_CHECK(glEnable(GL_BLEND));
    GL_CHECK(glGenTextures(1, &texName));
    GL_CHECK(glBindTexture(GL_TEXTURE_2D, texName));
	 
    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()
Changes to generic/gles2FreeType.c.
188
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
204
205


206
207
208
209
210
211
212

int
Gles2_GetFreeTypeInfo(
    Tcl_Interp *interp,
    Gles2WidgetImageInfo *infoPtr,
    const char *fontName,
    int fontSize,
    RgbaInfo *rgbaPtr,

    Tcl_Obj *textPtr,
    Gles2WidgetImage *wgtPtr,
    int measureOnly)
{
    Gles2FreeTypeString *ftInfoPtr;
    GLubyte *bitmap;
    int numRgbaBytes;
    int result;
    int bottom;
    int i;



    wgtPtr->unitext = Tcl_GetUnicodeFromObj(textPtr, &wgtPtr->unitextlen);
    if (wgtPtr->unitextlen <= 0) {
        Tcl_SetResult (interp, "string must not be empty", TCL_STATIC);
        return TCL_ERROR;
    }
    if (wgtPtr->fontInfo == NULL) {







|
>










>
>







188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215

int
Gles2_GetFreeTypeInfo(
    Tcl_Interp *interp,
    Gles2WidgetImageInfo *infoPtr,
    const char *fontName,
    int fontSize,
    RgbaInfo *backgroundrgbaPtr,
    RgbaInfo *foregroundrgbaPtr,
    Tcl_Obj *textPtr,
    Gles2WidgetImage *wgtPtr,
    int measureOnly)
{
    Gles2FreeTypeString *ftInfoPtr;
    GLubyte *bitmap;
    int numRgbaBytes;
    int result;
    int bottom;
    int i;
int j;
char *cp;

    wgtPtr->unitext = Tcl_GetUnicodeFromObj(textPtr, &wgtPtr->unitextlen);
    if (wgtPtr->unitextlen <= 0) {
        Tcl_SetResult (interp, "string must not be empty", TCL_STATIC);
        return TCL_ERROR;
    }
    if (wgtPtr->fontInfo == NULL) {
259
260
261
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
    }
    /* 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 r!%d!g!%d!b!%d!@:%d!\n", rgbaPtr->Color[0], rgbaPtr->Color[1], rgbaPtr->Color[2], rgbaPtr->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, 0, wgtPtr->dataSize);
fprintf(stderr, "dS!%d!%d!\n", wgtPtr->dataSize, wgtPtr->typeEntryBytes);
        wgtPtr->data = bitmap;
















        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;







|
>












|


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







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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
    }
    /* 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];
    }
    if (j % 4 == 1) {
      *cp = backgroundrgbaPtr->Color[2];
    }
    if (j % 4 == 2) {
      *cp = backgroundrgbaPtr->Color[3];
    }
    if (j % 4 == 3) {
      *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;
313
314
315
316
317
318
319

320
321
322
323
324








325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341

342
343
344
345
346
347
348
349
#ifdef ORIGIN_IS_BOTTOM_LEFT
            for (ty = ftInfoPtr->bitmap.rows-1, y = desty; ty >= 0 &&
	            y >= 0 && y < wgtPtr->height; --ty, ++y) {
#else
            for (ty = 0, y = desty; ty < ftInfoPtr->bitmap.rows &&
	            y >= 0 && y < wgtPtr->height; ++ty, ++y) {
#endif

                for (tx = 0, x = wgtPtr->width - 1 - destx; tx < ftInfoPtr->bitmap.width && x >= 0 &&
	                x < wgtPtr->width; ++tx, --x) {
                    dp = bitmap + (y*wgtPtr->width*numRgbaBytes) + (x*numRgbaBytes);
                    ch = ftInfoPtr->bitmap.buffer[ty*ftInfoPtr->bitmap.pitch+tx];
//fprintf(stderr, "offset!ch!%c!%d!tx!%d!ty!%d!%d!\n", wgtPtr->unitext[i], ch, tx, ty, (y*wgtPtr->width*numRgbaBytes) + (x*numRgbaBytes));








                    if (ch == 0) {
                    dp[0] = 0;
                    dp[1] = 0;
                    dp[2] = 125;
                    dp[3] = 0;
	                continue;
	            }
                    fpdelta = /*peak value*/ 255 - ch;
                    finalalpha = rgbaPtr->Color[3];
                    if (fpdelta > finalalpha) {
                        finalalpha = 0;
                    } else {
                        finalalpha -= fpdelta;
                    }
                    dp[0] = rgbaPtr->Color[0];
                    dp[1] = rgbaPtr->Color[1];
                    dp[2] = rgbaPtr->Color[2];

                    dp[3] = finalalpha;
//fprintf(stderr, "dp!%d!%d!%d!%d!\n", dp[0], dp[1], dp[2], dp[3]);
                }
            }
            destx += ftInfoPtr->width;
            ckfree((char *)ftInfoPtr->bitmap.buffer);
        }
    }







>





>
>
>
>
>
>
>
>

|
|
|
|



|





|
|
|
>
|







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#ifdef ORIGIN_IS_BOTTOM_LEFT
            for (ty = ftInfoPtr->bitmap.rows-1, y = desty; ty >= 0 &&
	            y >= 0 && y < wgtPtr->height; --ty, ++y) {
#else
            for (ty = 0, y = desty; ty < ftInfoPtr->bitmap.rows &&
	            y >= 0 && y < wgtPtr->height; ++ty, ++y) {
#endif
                /* Attention we have to fill each row from the end !! Don't know why */
                for (tx = 0, x = wgtPtr->width - 1 - destx; tx < ftInfoPtr->bitmap.width && x >= 0 &&
	                x < wgtPtr->width; ++tx, --x) {
                    dp = bitmap + (y*wgtPtr->width*numRgbaBytes) + (x*numRgbaBytes);
                    ch = ftInfoPtr->bitmap.buffer[ty*ftInfoPtr->bitmap.pitch+tx];
//fprintf(stderr, "offset!ch!%c!%d!tx!%d!ty!%d!%d!\n", wgtPtr->unitext[i], ch, tx, ty, (y*wgtPtr->width*numRgbaBytes) + (x*numRgbaBytes));
//fprintf(stderr, "ch!0x%02x!%d!%d!%d!%d!\n", ch, foregroundrgbaPtr->Color[0], foregroundrgbaPtr->Color[1], foregroundrgbaPtr->Color[2], foregroundrgbaPtr->Color[3]);
//                    fpdelta = /*peak value*/ 255 - ch;
//                    finalalpha = rgbaPtr->Color[3];
//                    if (fpdelta > finalalpha) {
//                        finalalpha = 0;
//                    } else {
//                        finalalpha -= fpdelta;
//                    }
                    if (ch == 0) {
//                    dp[0] = 0;
//                    dp[1] = 255;
//                    dp[2] = 0;
//                    dp[3] = 255;
	                continue;
	            }
                    fpdelta = /*peak value*/ 255 - ch;
                    finalalpha = foregroundrgbaPtr->Color[3];
                    if (fpdelta > finalalpha) {
                        finalalpha = 0;
                    } else {
                        finalalpha -= fpdelta;
                    }
                    dp[0] = foregroundrgbaPtr->Color[0];
                    dp[1] = foregroundrgbaPtr->Color[1];
                    dp[2] = foregroundrgbaPtr->Color[2];
                    dp[3] = foregroundrgbaPtr->Color[3];
//                    dp[3] = finalalpha;
//fprintf(stderr, "dp!%d!%d!%d!%d!\n", dp[0], dp[1], dp[2], dp[3]);
                }
            }
            destx += ftInfoPtr->width;
            ckfree((char *)ftInfoPtr->bitmap.buffer);
        }
    }
Changes to generic/gles2Helpers.c.
488
489
490
491
492
493
494




















495
496
497

498
499
500
501
502
503
504
              {
                /* no known format */
fprintf(stderr, "ColorValue2RGBA no known format: %s\n", Tcl_GetString(obj));
	        return NULL;
              }
            }
        } else {




















            /* color names not yet implemented */
fprintf(stderr, "ColorValue2RGBA color names not yet implemented: %s\n", Tcl_GetString(obj));
	    return NULL;

        }
      }
    default:
      {
        /* no known format */
fprintf(stderr, "ColorValue2RGBA no known format: %s\n", Tcl_GetString(obj));
	return NULL;







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



>







488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
              {
                /* no known format */
fprintf(stderr, "ColorValue2RGBA no known format: %s\n", Tcl_GetString(obj));
	        return NULL;
              }
            }
        } else {
            if (strcmp(Tcl_GetString(obj), "black") == 0) {
                listObj = Tcl_NewListObj(0, NULL);
	        if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewDoubleObj(0.0)) != TCL_OK) {
fprintf(stderr, "ColorValue2RGBA could not append red value: %s\n", Tcl_GetString(obj));
	            return NULL;
	        }
	        if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewDoubleObj(0.0)) != TCL_OK) {
fprintf(stderr, "ColorValue2RGBA could not append green value: %s\n", Tcl_GetString(obj));
	            return NULL;
	        }
	        if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewDoubleObj(0.0)) != TCL_OK) {
fprintf(stderr, "ColorValue2RGBA could not append blue value: %s\n", Tcl_GetString(obj));
	            return NULL;
	        }
	        if (Tcl_ListObjAppendElement(interp, listObj, Tcl_NewDoubleObj(1.0)) != TCL_OK) {
fprintf(stderr, "ColorValue2RGBA could not append alpha value: %s\n", Tcl_GetString(obj));
	            return NULL;
	        }
	        return listObj;
            } else {
            /* color names not yet implemented */
fprintf(stderr, "ColorValue2RGBA color names not yet implemented: %s\n", Tcl_GetString(obj));
	    return NULL;
            }
        }
      }
    default:
      {
        /* no known format */
fprintf(stderr, "ColorValue2RGBA no known format: %s\n", Tcl_GetString(obj));
	return NULL;
Changes to generic/gles2Int.h.
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    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 *rgbaPtr, Tcl_Obj *textPtr, Gles2WidgetImage *wgtPtr,
        int measureOnly);
MODULE_SCOPE int Gles2_GetFreeTypeOffsetMap(Tcl_Interp *interp,
        Gles2WidgetImage *wgtPtr, Tcl_Obj *listPtr);
MODULE_SCOPE GLfloat Pixel2Coord(Tcl_Interp *interp, int pixels, int useWidth);
MODULE_SCOPE int Value2Pixel(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * ColorValue2RGBA(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * GetElementPositions(Tcl_Interp *interp, Tcl_Obj *obj);







|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    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,
        int measureOnly);
MODULE_SCOPE int Gles2_GetFreeTypeOffsetMap(Tcl_Interp *interp,
        Gles2WidgetImage *wgtPtr, Tcl_Obj *listPtr);
MODULE_SCOPE GLfloat Pixel2Coord(Tcl_Interp *interp, int pixels, int useWidth);
MODULE_SCOPE int Value2Pixel(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * ColorValue2RGBA(Tcl_Interp *interp, Tcl_Obj *obj);
MODULE_SCOPE Tcl_Obj * GetElementPositions(Tcl_Interp *interp, Tcl_Obj *obj);