/usr/include/Wt/WGLWidget is in libwt-dev 3.3.3+dfsg-4.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 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 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 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 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 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 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 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 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 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 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 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 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 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 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 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 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 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2010 Emweb bvba, Leuven, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WGLWIDGET_H_
#define WGLWIDGET_H_
#include <Wt/WInteractWidget>
#include <Wt/WGenericMatrix>
#include <Wt/WMatrix4x4>
#ifndef WT_TARGET_JAVA
namespace Wt {
typedef std::vector<float> FloatBuffer;
typedef std::vector<int> IntBuffer;
}
#else
#include <java/buffer>
#endif
namespace Wt {
// define to enable WebGL debug code
#define WT_WGLWIDGET_DEBUG
#ifdef WT_TARGET_JAVA
#define __FUNCTION__ "(unknown)"
#endif
#ifdef WT_WGLWIDGET_DEBUG
#define GLDEBUG do {if (debugging_) {js_ << "\n{var err = ctx.getError(); if(err != ctx.NO_ERROR) {alert('error " << __FUNCTION__ << ": ' + err); debugger;}}\n";}} while(false)
//if (glGetError() != GL_NO_ERROR){}
#define SERVERGLDEBUG do {if (debugging_) {int err = glGetError(); if (err != GL_NO_ERROR){std::cerr << "gl error occured in " << __FUNCTION__ << ": " << err << std::endl;}} } while(false)
//#define GLDEBUG do {js_ << "\n{var err = ctx.getError(); if(err != ctx.NO_ERROR) {debugger;}}\n";} while(false)
#else
#define GLDEBUG
#endif
class WAbstractGLImplementation;
class WPaintDevice;
#if !defined(WT_TARGET_JAVA)
#define WT_WGL_TEMPLATE(...) template < __VA_ARGS__ >
#else
#define WT_WGL_TEMPLATE(...)
#endif
class WHTML5Video;
class WImage;
enum JsArrayType {
Array,
Float32Array
};
// Incomplete implementation of the new webgl standard. This is to be
// considered as a technology preview, and we welcome comments regarding
// this interface.
// Expect this interface to change.
// TODO: provide a mechanism to write your own JavaScript
/*! \class WGLWidget Wt/WGLWidget Wt/WGLWidget
* \brief WebGL support class
*
* The WGLWidget class is an interface to the HTML5 WebGL infrastructure. Its
* implementation started based on the working drafts of the Khronos group, and
* will be updated as the standard stabilizes. To fully understand WebGL, it is
* recommended to read the WebGL standard in addition to this documentation.
*
* The most recent version of the WebGL specification can be found here:
* https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html
*
* This widget is work in progress. The API may change in the future because
* of new features, reorganizations or changes in the WebGL draft.
*
* The goal of the WGLWidget class is to provide a method to render 3D
* structures in the browser, where rendering and rerendering is normally
* done at the client side in JavaScript without interaction from the server,
* in order to obtain a smooth user interaction. Unless the scene requires
* server-side updates, there is no communication with the server.
*
* The rendering interface resembles to OpenGL ES, the same standard as
* WebGL is based on. This is a stripped down version of the normal OpenGL
* as we usually find them on desktops. Many stateful OpenGL features are
* not present in OpenGL ES: no modelview and camera transformation stacks,
* no default lighting models, no support for other rendering methods than
* through VBOs, ... Therefore much existing example code for OpenGL
* applications and shaders will not work on WebGL without modifications.
* The 'learning webgl' web site at http://learningwebgl.com/ is a good
* starting point to get familiar with WebGL.
*
* To use a %WGLWidget, you must derive from it and reimplement
* the painter methods. Usually, you will always need to implement
* initializeGL() and paintGL(). Optionally, you may choose to implement
* resizeGL() (if your widget does not have a fixed size), and updateGL().
* If you need to modify the painting methods, a repaint is triggered by
* calling the repaintGL() method. The default behaviour for any of these
* four painting functions is to do nothing.
*
* The four painter methods (initializeGL(), resizeGL(), paintGL() and
* updateGL()) all record JavaScript which is sent to the
* browser. The JavaScript code of paintGL() is cached client-side, and
* may be executed many times, e.g. to repaint a scene from different
* viewpoints. The JavaScript code of initializeGL(), resizeGL() and
* updateGL() are intended for OpenGL state updates, and is therefore
* only executed once on the client and is then discarded.
*
* There are four painting methods that you may implement in a
* specialization of this class. The purpose of these functions is
* to register what JavaScript code has to be executed to render a
* scene. Through invocations of the WebGL functions documented below,
* Wt records the JavaScript calls that have to be invoked in the
* browser.
* <ul>
* <li><b>initializeGL()</b>: this function is executed only once, right
* after the successful detection of WebGL in the browser. (note: in
* future versions, it may be re-executed when the webglcontextlost
* signal is fired, but this is currently not yet implemented). This
* is the ideal location to compose shader programs, send VBO's to
* the client, extract uniform and attribute locations, ... Due to
* the presence of VBO's, this function may generate a large amount
* of data to the client.
* <li><b>resizeGL()</b>: this function is executed whenever the canvas
* dimensions change. A change in canvas size will require you to
* invoke the viewport() function again, as well as recalculate the
* projection matrices (especially when the aspect ratio has changed).
* The resizeGL() function is therefore the ideal location to set those
* properties.
* The resizeGL() function is invoked automatically on every resize,
* and after the first initializeGL() invocation. Additional invocations
* may be triggered by calling repaint() with the RESIZE_GL flag.
* <li><b>paintGL()</b>: this is the main scene drawing function. Through
* its execution, Wt records what has to be done to render a scene,
* and it is executed every time that the scene is to be redrawn. You
* can use the VBO's and shaders prepared in the initializeGL() phase.
* Usually, this function sets uniforms and attributes, links
* attributes to VBO's, applies textures, and draws primitives.
* You may also create local programs, buffers, ... Remeber that this
* function is executed a lot of times, so every buffer/program created
* in this function should also be destroyed to avoid memory leaks.
* This function is transmitted once to the client, and is executed
* when the scene needs to be redrawn. Redraws may be triggered from
* mouse events, timer triggers, events on e.g. a video element, or
* whatever other event.
* The paintGL() function can be updated through invoking repaintGL()
* with the PAINT_GL flag.
* <li><b>updateGL()</b>: VBO's, programs, uniforms, GL properties,
* or anything else set during intializeGL() are not necessarily
* immutable. If you want to change, add, remove or reconfigure those
* properties, the execution of an updateGL() function can be triggered
* by invoking repaintGL() with the UPDATE_GL flag. This signals that
* updateGL() needs to be evaluated - just once. It is possible that
* the paintGL() function also requires updates as consequence of the
* changes in the updateGL() function; in this case, you should also set
* the PAINT_GL flag of repaintGL().
* </ul>
*
* The WebGL functions are intended to be used exclusively from within the
* invocation of the four callback functions mentioned above. In order to
* manually trigger the execution of these function, use the repaintGL().
*
* A WGLWidget must be given a size explicitly, or must be put inside a
* layout manager that manages its width and height. The behaviour of a
* WGLWidget that was not given a size is undefined.
*
* <h3>Binary buffer transfers</h3>
*
* In bufferDatafv(), there is an additional boolean argument where you
* can indicate that you want the data to be transferred to the client in
* binary form. A WMemoryResource is created for each of these buffers. If
* you know all previous resources are not required in the client anymore,
* you can free memory with the method clearBinaryResources() (the memory
* is also managed, so this is not neccesary). If you want to manage these
* resources entirely by yourself, the following method can be used.
*
* Using createAndLoadArrayBuffer(), you can load an array buffer in
* binary format from an URL. This will cause the client to fetch the
* given URL, and make the contents of the file available in an
* ArrayBuffer, which can then be used by BufferData() to bind them
* to an OpenGL buffer. This is ideal to load VBO buffers in a faster
* way, as it avoids converting floats to text strings on the server
* and then back to floats on the client. You can combine this with
* the use of WResource (e.g. WMemoryResource) to send an std::vector of
* vertices to the client. Note that using ArrayBuffer is not possible when
* you want a fall-back in the form of server-side rendering.
*
* <h3>Client side matrices.</h3>
*
* The WGLWidget provides the WGLWidget::JavaScriptMatrix4x4 class as
* a mechanism to use client-side modifiable matrices in the render
* functions. These matrices can be used identically to the
* 'constant', with the advantage that there is no need to have a
* roundtrip to the server to redraw the scene when they are changed.
* As such, they are ideal for mouse-based camera manipulations, timer
* triggered animations, or object manipulations.
*
* Note: the client side matrices are currently not yet communicated back
* to the server, but that is an implementation idea for the future.
*/
class WT_API WGLWidget: public WInteractWidget
{
#ifdef WT_TARGET_JAVA
typedef float FloatArray;
typedef int IntArray;
typedef double MatrixType;
#endif
public:
//! Abstract base class for all GL objects
class WT_API GlObject {
public:
GlObject(): id_(-1) {}
GlObject(int id) :
id_(id) {}
virtual std::string jsRef() const = 0;
int getId() const { return id_; }
void clear() { id_ = -1; }
bool isNull() const { return id_ == -1; }
private:
int id_;
};
//! Reference to a WebGLShader class
class WT_API Shader : public GlObject {
public:
Shader() {}
explicit Shader(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("Shader: is null");
return std::string("ctx.WtShader") + boost::lexical_cast<std::string>(getId());
}
};
//! Reference to a WebGLProgram class
class WT_API Program : public GlObject {
public:
Program() {}
explicit Program(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("Program: is null");
return std::string("ctx.WtProgram") + boost::lexical_cast<std::string>(getId());
}
};
//! Reference to a shader attribute location
class WT_API AttribLocation : public GlObject {
public:
AttribLocation() {}
explicit AttribLocation(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("AttribLocation: is null");
return std::string("ctx.WtAttrib") + boost::lexical_cast<std::string>(getId());
}
};
//! Reference to a WebGLBuffer class
class WT_API Buffer : public GlObject {
public:
Buffer() {}
explicit Buffer(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("Buffer: is null");
return std::string("ctx.WtBuffer") + boost::lexical_cast<std::string>(getId());
}
};
//! Reference to a WebGLUniformLocation class
class WT_API UniformLocation : public GlObject {
public:
UniformLocation() {}
explicit UniformLocation(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("UniformLocation: is null");
return std::string("ctx.WtUniform") + boost::lexical_cast<std::string>(getId());
}
};
//! Reference to a WebGLTexture class
class WT_API Texture: public GlObject {
public:
Texture()
: url_("")
{}
explicit Texture(int i) :
GlObject(i) {}
virtual std::string jsRef() const {
if (isNull())
throw WException("Texture: is null");
return std::string("ctx.WtTexture") + boost::lexical_cast<std::string>(getId());
}
void setUrl(std::string url) {
url_ = url;
}
const std::string& url() const {
return url_;
}
private:
std::string url_;
};
//! Reference to a WebGLFramebuffer class
class WT_API Framebuffer : public GlObject {
public:
Framebuffer() {}
Framebuffer(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("FrameBuffer: is null");
return "ctx.WtFramebuffer" + boost::lexical_cast<std::string>(getId());
}
};
//! Reference to a WebGLRenderbuffer class
class WT_API Renderbuffer : public GlObject {
public:
Renderbuffer() {}
Renderbuffer(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("RenderBuffer: is null");
return "ctx.WtRenderbuffer" + boost::lexical_cast<std::string>(getId());
}
};
/*!
* \brief Reference to a javascript %ArrayBuffer class
*/
class WT_API ArrayBuffer : public GlObject {
public:
ArrayBuffer() {}
ArrayBuffer(int i) :
GlObject(i) {}
std::string jsRef() const {
if (isNull())
throw WException("ArrayBuffer: is null");
return "ctx.WtBufferResource" + boost::lexical_cast<std::string>(getId());
}
};
/*! \brief A client-side JavaScript matrix
*
* A JavaScriptMatrix has methods that make it possible to do client-side
* calculations on matrices.
*
* Important: only the jsRef() of the return value from a call to
* WGLWidget::createJavaScriptMatrix() is a variable name that can be used
* in custom JavaScript to modify a matrix from external scripts.
* The jsRef() of return values of operations refer to unnamed temporary
* objects - rvalues in C++-lingo.
*/
class WT_API JavaScriptMatrix4x4 {
public:
// Create temporarily invalid JSMatrix4x4, should be initialized
// later with createJavaScriptMatrix()
JavaScriptMatrix4x4();
#ifndef WT_TARGET_JAVA
JavaScriptMatrix4x4(const JavaScriptMatrix4x4 &other);
JavaScriptMatrix4x4 &operator=(const JavaScriptMatrix4x4 &rhs);
#endif
int id() const { return id_; }
std::string jsRef() const {
if (id() == -1)
throw WException("JavaScriptMatrix4x4: matrix not initialized");
return jsRef_;
}
JavaScriptMatrix4x4 inverted() const;
JavaScriptMatrix4x4 transposed() const;
#if !defined(WT_TARGET_JAVA)
JavaScriptMatrix4x4 operator*(const WGenericMatrix<double, 4, 4> &m) const;
#else
JavaScriptMatrix4x4 multiply(const WGenericMatrix<MatrixType, 4, 4> &m) const;
#endif
WMatrix4x4 value() const;
#ifdef WT_TARGET_JAVA
JavaScriptMatrix4x4 clone() const;
#endif
private:
JavaScriptMatrix4x4(int i, JsArrayType type, const WGLWidget* context);
bool hasOperations() const { return operations_.size() > 0;}
// void invert();
// void transpose();
// void mul(const WGenericMatrix<double, 4, 4> &m);
int id_;
std::string jsRef_;
const WGLWidget* context_;
JsArrayType arrayType_;
enum op {TRANSPOSE, INVERT, MULTIPLY};
std::vector<op> operations_;
std::vector< WGenericMatrix<double, 4, 4> > matrices_;
friend class WGLWidget;
friend class WServerGLWidget;
friend class WClientGLWidget;
};
/*! \brief Enumeration for render options
*
* \sa setRenderOptions()
*/
enum RenderOption {
ClientSideRendering = 0x1, //<! Enables client-side rendering
ServerSideRendering = 0x2 //<! Enables server-side rendering
};
/*! \brief Construct a WebGL widget.
*
* Before the first rendering, you must apply a size to the WGLWidget.
*/
WGLWidget(WContainerWidget *parent = 0);
/*! \brief Destructor
*/
~WGLWidget();
/*! \brief Sets the rendering option.
*
* Use this method to configure whether client-side and/or
* server-side rendering can be used. The actual choice is also based
* on availability (respectively client-side or server-side).
*
* The default value is to try both ClientSide or ServerSide rendering.
*
* \note Options must be set before the widget is being rendered.
*/
void setRenderOptions(WFlags<RenderOption> options);
/*! \brief Initialize the WebGL state when the widget is first shown.
*
* initializeGL() is called once, when the widget is first rendered. It
* usually creates most of the WebGL related state: shaders, VBOs,
* uniform locations, ...
*
* If this state is to be updated during the lifetime of the widget,
* you should specialize the updateGL() to accomodate for this.
*
* Note: in a future version, this method will probably also be invoked
* on contextrestore events.
*/
virtual void initializeGL();
/*! \brief Act on resize events
*
* Usually, this method only contains functions to set the viewport
* and the projection matrix (as this is aspect ration dependent).
*
* resizeGL() is rendered after initializeGL, and whenever widget is
* resized. After this method finishes, the widget is repainted with
* the cached client-side paint function.
*/
virtual void resizeGL(int width, int height);
/*! \brief Update the client-side painting function.
*
* This method is invoked client-side when a repaint is required,
* i.e. when the repaintSlot() (a JavaScript-side JSlot) is triggered.
* Typical examples are: after mouse-based camera movements, after
* a timed update of a camera or an object's position, after
* a resize event (resizeGL() will also be called then), after
* an animation event, ... In many cases, this function will be
* executed client-side many many times.
*
* Using the WebGL functions from this class, you construct a scene.
* The implementation tracks all JavaScript calls that need to be
* performed to draw the scenes, and will replay them verbatim on
* every trigger of the repaintSlot(). There are a few mechanisms
* that may be employed to change what is rendered without updating
* the paintGL() cache:
* <ul>
* <li>Client-side matrices may be used to change camera viewpoints,
* manipilate separate object's model transformation matrices, ...
* </li>
* <li>Shader sources can be updated without requiring the paint
* function to be renewed</li>
* </ul>
*
* Updating the paintGL() cache is usually not too expensive; the VBOs,
* which are large in many cases, are already at the client side, while
* the paintGL() code only draws the VBOs. Of course, if you have to
* draw many separate objects, the paintGL() JS code may become large
* and updating is more expensive.
*
* In order to update the paintGL() cache, call repaintGL() with
* the PAINT_GL parameter, which will cause the invocation of this
* method.
*/
virtual void paintGL();
/*! \brief Update state set in initializeGL()
*
* Invoked when repaint is called with the UPDATE_GL call.
*
* This is intended to be executed when you want to change programs,
* 'constant' uniforms, or even VBO's, ... without resending already
* initialized data. It is a mechanism to make changes to what you've
* set in intializeGL(). For every server-side invocation of this method,
* the result will be rendered client-side exactly once.
*/
virtual void updateGL();
/*! \brief Specifies what WebGL function needs to be updated
*/
enum ClientSideRenderer {PAINT_GL = 0x1, //!< refresh paintGL()
RESIZE_GL = 0x2, //!< refresh resizeGL()
UPDATE_GL = 0x4 //!< refresh updateGL()
};
/*! \brief Request invocation of resizeGL, paintGL and/or updateGL.
*
* If invoked with PAINT_GL, the client-side cached paint function
* is updated. If invoked with RESIZE_GL or UPDATE_GL, the code
* will be executed once.
*
* If invoked with multiple flags set, the order of execution will be
* updateGL(), resizeGL(), paintGL().
*/
void repaintGL(WFlags<ClientSideRenderer> which);
void resize(const WLength &width, const WLength &height);
/*! \brief The enourmous GLenum
*
* This enum contains all numeric constants defined by the WebGL standard.
*/
enum GLenum {
/* ClearBufferMask */
DEPTH_BUFFER_BIT = 0x00000100,
STENCIL_BUFFER_BIT = 0x00000400,
COLOR_BUFFER_BIT = 0x00004000,
/* BeginMode */
POINTS = 0x0000,
LINES = 0x0001,
LINE_LOOP = 0x0002,
LINE_STRIP = 0x0003,
TRIANGLES = 0x0004,
TRIANGLE_STRIP = 0x0005,
TRIANGLE_FAN = 0x0006,
/* AlphaFunction (not supported in ES20) */
/* NEVER */
/* LESS */
/* EQUAL */
/* LEQUAL */
/* GREATER */
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* BlendingFactorDest */
ZERO = 0x0,
ONE = 0x1,
SRC_COLOR = 0x0300,
ONE_MINUS_SRC_COLOR = 0x0301,
SRC_ALPHA = 0x0302,
ONE_MINUS_SRC_ALPHA = 0x0303,
DST_ALPHA = 0x0304,
ONE_MINUS_DST_ALPHA = 0x0305,
/* BlendingFactorSrc */
/* ZERO */
/* ONE */
DST_COLOR = 0x0306,
ONE_MINUS_DST_COLOR = 0x0307,
SRC_ALPHA_SATURATE = 0x0308,
/* SRC_ALPHA */
/* ONE_MINUS_SRC_ALPHA */
/* DST_ALPHA */
/* ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
FUNC_ADD = 0x8006,
BLEND_EQUATION = 0x8009,
BLEND_EQUATION_RGB = 0x8009, /* same as BLEND_EQUATION */
BLEND_EQUATION_ALPHA = 0x883D,
/* BlendSubtract */
FUNC_SUBTRACT = 0x800A,
FUNC_REVERSE_SUBTRACT = 0x800B,
/* Separate Blend Functions */
BLEND_DST_RGB = 0x80C8,
BLEND_SRC_RGB = 0x80C9,
BLEND_DST_ALPHA = 0x80CA,
BLEND_SRC_ALPHA = 0x80CB,
CONSTANT_COLOR = 0x8001,
ONE_MINUS_CONSTANT_COLOR = 0x8002,
CONSTANT_ALPHA = 0x8003,
ONE_MINUS_CONSTANT_ALPHA = 0x8004,
BLEND_COLOR = 0x8005,
/* Buffer Objects */
ARRAY_BUFFER = 0x8892,
ELEMENT_ARRAY_BUFFER = 0x8893,
ARRAY_BUFFER_BINDING = 0x8894,
ELEMENT_ARRAY_BUFFER_BINDING = 0x8895,
STREAM_DRAW = 0x88E0,
STATIC_DRAW = 0x88E4,
DYNAMIC_DRAW = 0x88E8,
BUFFER_SIZE = 0x8764,
BUFFER_USAGE = 0x8765,
CURRENT_VERTEX_ATTRIB = 0x8626,
/* CullFaceMode */
FRONT = 0x0404,
BACK = 0x0405,
FRONT_AND_BACK = 0x0408,
/* DepthFunction */
/* NEVER */
/* LESS */
/* EQUAL */
/* LEQUAL */
/* GREATER */
/* NOTEQUAL */
/* GEQUAL */
/* ALWAYS */
/* EnableCap */
/* TEXTURE_2D */
CULL_FACE = 0x0B44,
BLEND = 0x0BE2,
DITHER = 0x0BD0,
STENCIL_TEST = 0x0B90,
DEPTH_TEST = 0x0B71,
SCISSOR_TEST = 0x0C11,
POLYGON_OFFSET_FILL = 0x8037,
SAMPLE_ALPHA_TO_COVERAGE = 0x809E,
SAMPLE_COVERAGE = 0x80A0,
/* ErrorCode */
NO_ERROR = 0x0,
INVALID_ENUM = 0x0500,
INVALID_VALUE = 0x0501,
INVALID_OPERATION = 0x0502,
OUT_OF_MEMORY = 0x0505,
/* FrontFaceDirection */
CW = 0x0900,
CCW = 0x0901,
/* GetPName */
LINE_WIDTH = 0x0B21,
ALIASED_POINT_SIZE_RANGE = 0x846D,
ALIASED_LINE_WIDTH_RANGE = 0x846E,
CULL_FACE_MODE = 0x0B45,
FRONT_FACE = 0x0B46,
DEPTH_RANGE = 0x0B70,
DEPTH_WRITEMASK = 0x0B72,
DEPTH_CLEAR_VALUE = 0x0B73,
DEPTH_FUNC = 0x0B74,
STENCIL_CLEAR_VALUE = 0x0B91,
STENCIL_FUNC = 0x0B92,
STENCIL_FAIL = 0x0B94,
STENCIL_PASS_DEPTH_FAIL = 0x0B95,
STENCIL_PASS_DEPTH_PASS = 0x0B96,
STENCIL_REF = 0x0B97,
STENCIL_VALUE_MASK = 0x0B93,
STENCIL_WRITEMASK = 0x0B98,
STENCIL_BACK_FUNC = 0x8800,
STENCIL_BACK_FAIL = 0x8801,
STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802,
STENCIL_BACK_PASS_DEPTH_PASS = 0x8803,
STENCIL_BACK_REF = 0x8CA3,
STENCIL_BACK_VALUE_MASK = 0x8CA4,
STENCIL_BACK_WRITEMASK = 0x8CA5,
VIEWPORT = 0x0BA2,
SCISSOR_BOX = 0x0C10,
/* SCISSOR_TEST */
COLOR_CLEAR_VALUE = 0x0C22,
COLOR_WRITEMASK = 0x0C23,
UNPACK_ALIGNMENT = 0x0CF5,
PACK_ALIGNMENT = 0x0D05,
MAX_TEXTURE_SIZE = 0x0D33,
MAX_VIEWPORT_DIMS = 0x0D3A,
SUBPIXEL_BITS = 0x0D50,
RED_BITS = 0x0D52,
GREEN_BITS = 0x0D53,
BLUE_BITS = 0x0D54,
ALPHA_BITS = 0x0D55,
DEPTH_BITS = 0x0D56,
STENCIL_BITS = 0x0D57,
POLYGON_OFFSET_UNITS = 0x2A00,
/* POLYGON_OFFSET_FILL */
POLYGON_OFFSET_FACTOR = 0x8038,
TEXTURE_BINDING_2D = 0x8069,
SAMPLE_BUFFERS = 0x80A8,
SAMPLES = 0x80A9,
SAMPLE_COVERAGE_VALUE = 0x80AA,
SAMPLE_COVERAGE_INVERT = 0x80AB,
/* GetTextureParameter */
/* TEXTURE_MAG_FILTER */
/* TEXTURE_MIN_FILTER */
/* TEXTURE_WRAP_S */
/* TEXTURE_WRAP_T */
NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2,
COMPRESSED_TEXTURE_FORMATS = 0x86A3,
/* HintMode */
DONT_CARE = 0x1100,
FASTEST = 0x1101,
NICEST = 0x1102,
/* HintTarget */
GENERATE_MIPMAP_HINT = 0x8192,
/* DataType */
BYTE = 0x1400,
UNSIGNED_BYTE = 0x1401,
SHORT = 0x1402,
UNSIGNED_SHORT = 0x1403,
INT = 0x1404,
UNSIGNED_INT = 0x1405,
FLOAT = 0x1406,
/* PixelFormat */
DEPTH_COMPONENT = 0x1902,
ALPHA = 0x1906,
RGB = 0x1907,
RGBA = 0x1908,
LUMINANCE = 0x1909,
LUMINANCE_ALPHA = 0x190A,
/* PixelType */
/* UNSIGNED_BYTE */
UNSIGNED_SHORT_4_4_4_4 = 0x8033,
UNSIGNED_SHORT_5_5_5_1 = 0x8034,
UNSIGNED_SHORT_5_6_5 = 0x8363,
/* Shaders */
FRAGMENT_SHADER = 0x8B30,
VERTEX_SHADER = 0x8B31,
MAX_VERTEX_ATTRIBS = 0x8869,
MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB,
MAX_VARYING_VECTORS = 0x8DFC,
MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C,
MAX_TEXTURE_IMAGE_UNITS = 0x8872,
MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD,
SHADER_TYPE = 0x8B4F,
DELETE_STATUS = 0x8B80,
LINK_STATUS = 0x8B82,
VALIDATE_STATUS = 0x8B83,
ATTACHED_SHADERS = 0x8B85,
ACTIVE_UNIFORMS = 0x8B86,
ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87,
ACTIVE_ATTRIBUTES = 0x8B89,
ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A,
SHADING_LANGUAGE_VERSION = 0x8B8C,
CURRENT_PROGRAM = 0x8B8D,
/* StencilFunction */
NEVER = 0x0200,
LESS = 0x0201,
EQUAL = 0x0202,
LEQUAL = 0x0203,
GREATER = 0x0204,
NOTEQUAL = 0x0205,
GEQUAL = 0x0206,
ALWAYS = 0x0207,
/* StencilOp */
/* ZERO */
KEEP = 0x1E00,
REPLACE = 0x1E01,
INCR = 0x1E02,
DECR = 0x1E03,
INVERT = 0x150A,
INCR_WRAP = 0x8507,
DECR_WRAP = 0x8508,
/* StringName */
VENDOR = 0x1F00,
RENDERER = 0x1F01,
VERSION = 0x1F02,
/* TextureMagFilter */
NEAREST = 0x2600,
LINEAR = 0x2601,
/* TextureMinFilter */
/* NEAREST */
/* LINEAR */
NEAREST_MIPMAP_NEAREST = 0x2700,
LINEAR_MIPMAP_NEAREST = 0x2701,
NEAREST_MIPMAP_LINEAR = 0x2702,
LINEAR_MIPMAP_LINEAR = 0x2703,
/* TextureParameterName */
TEXTURE_MAG_FILTER = 0x2800,
TEXTURE_MIN_FILTER = 0x2801,
TEXTURE_WRAP_S = 0x2802,
TEXTURE_WRAP_T = 0x2803,
/* TextureTarget */
TEXTURE_2D = 0x0DE1,
TEXTURE = 0x1702,
TEXTURE_CUBE_MAP = 0x8513,
TEXTURE_BINDING_CUBE_MAP = 0x8514,
TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515,
TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516,
TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517,
TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518,
TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519,
TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A,
MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C,
/* TextureUnit */
TEXTURE0 = 0x84C0,
TEXTURE1 = 0x84C1,
TEXTURE2 = 0x84C2,
TEXTURE3 = 0x84C3,
TEXTURE4 = 0x84C4,
TEXTURE5 = 0x84C5,
TEXTURE6 = 0x84C6,
TEXTURE7 = 0x84C7,
TEXTURE8 = 0x84C8,
TEXTURE9 = 0x84C9,
TEXTURE10 = 0x84CA,
TEXTURE11 = 0x84CB,
TEXTURE12 = 0x84CC,
TEXTURE13 = 0x84CD,
TEXTURE14 = 0x84CE,
TEXTURE15 = 0x84CF,
TEXTURE16 = 0x84D0,
TEXTURE17 = 0x84D1,
TEXTURE18 = 0x84D2,
TEXTURE19 = 0x84D3,
TEXTURE20 = 0x84D4,
TEXTURE21 = 0x84D5,
TEXTURE22 = 0x84D6,
TEXTURE23 = 0x84D7,
TEXTURE24 = 0x84D8,
TEXTURE25 = 0x84D9,
TEXTURE26 = 0x84DA,
TEXTURE27 = 0x84DB,
TEXTURE28 = 0x84DC,
TEXTURE29 = 0x84DD,
TEXTURE30 = 0x84DE,
TEXTURE31 = 0x84DF,
ACTIVE_TEXTURE = 0x84E0,
/* TextureWrapMode */
REPEAT = 0x2901,
CLAMP_TO_EDGE = 0x812F,
MIRRORED_REPEAT = 0x8370,
/* Uniform Types */
FLOAT_VEC2 = 0x8B50,
FLOAT_VEC3 = 0x8B51,
FLOAT_VEC4 = 0x8B52,
INT_VEC2 = 0x8B53,
INT_VEC3 = 0x8B54,
INT_VEC4 = 0x8B55,
BOOL = 0x8B56,
BOOL_VEC2 = 0x8B57,
BOOL_VEC3 = 0x8B58,
BOOL_VEC4 = 0x8B59,
FLOAT_MAT2 = 0x8B5A,
FLOAT_MAT3 = 0x8B5B,
FLOAT_MAT4 = 0x8B5C,
SAMPLER_2D = 0x8B5E,
SAMPLER_CUBE = 0x8B60,
/* Vertex Arrays */
VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622,
VERTEX_ATTRIB_ARRAY_SIZE = 0x8623,
VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624,
VERTEX_ATTRIB_ARRAY_TYPE = 0x8625,
VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A,
VERTEX_ATTRIB_ARRAY_POINTER = 0x8645,
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F,
/* Shader Source */
COMPILE_STATUS = 0x8B81,
INFO_LOG_LENGTH = 0x8B84,
SHADER_SOURCE_LENGTH = 0x8B88,
/* Shader Precision-Specified Types */
LOW_FLOAT = 0x8DF0,
MEDIUM_FLOAT = 0x8DF1,
HIGH_FLOAT = 0x8DF2,
LOW_INT = 0x8DF3,
MEDIUM_INT = 0x8DF4,
HIGH_INT = 0x8DF5,
/* Framebuffer Object. */
FRAMEBUFFER = 0x8D40,
RENDERBUFFER = 0x8D41,
RGBA4 = 0x8056,
RGB5_A1 = 0x8057,
RGB565 = 0x8D62,
DEPTH_COMPONENT16 = 0x81A5,
STENCIL_INDEX = 0x1901,
STENCIL_INDEX8 = 0x8D48,
DEPTH_STENCIL = 0x84F9,
RENDERBUFFER_WIDTH = 0x8D42,
RENDERBUFFER_HEIGHT = 0x8D43,
RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
RENDERBUFFER_RED_SIZE = 0x8D50,
RENDERBUFFER_GREEN_SIZE = 0x8D51,
RENDERBUFFER_BLUE_SIZE = 0x8D52,
RENDERBUFFER_ALPHA_SIZE = 0x8D53,
RENDERBUFFER_DEPTH_SIZE = 0x8D54,
RENDERBUFFER_STENCIL_SIZE = 0x8D55,
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0,
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1,
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2,
FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3,
COLOR_ATTACHMENT0 = 0x8CE0,
DEPTH_ATTACHMENT = 0x8D00,
STENCIL_ATTACHMENT = 0x8D20,
DEPTH_STENCIL_ATTACHMENT = 0x821A,
NONE = 0x0,
FRAMEBUFFER_COMPLETE = 0x8CD5,
FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7,
FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9,
FRAMEBUFFER_UNSUPPORTED = 0x8CDD,
FRAMEBUFFER_BINDING = 0x8CA6,
RENDERBUFFER_BINDING = 0x8CA7,
MAX_RENDERBUFFER_SIZE = 0x84E8,
INVALID_FRAMEBUFFER_OPERATION = 0x0506,
/* WebGL-specific enums */
UNPACK_FLIP_Y_WEBGL = 0x9240,
UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241,
CONTEXT_LOST_WEBGL = 0x9242,
UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243,
BROWSER_DEFAULT_WEBGL = 0x9244,
};
void debugger();
/*! @name WebGL methods
* The WebGL methods are mostly 1-on-1 translated to the identical
* JavaScript call. You can use the WebGL methods in your resizeGL(),
* paintGL() and updateGL() specializations. Wt takes care that data,
* arguments, ... are transfered to the client side and that the equivalent
* JavaScript WebGL funtion is executed.
* @{
*/
/*! \brief GL function to activate an existing texture
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glActiveTexture.xml">
* glActiveTexture() OpenGL ES manpage</a>
*/
void activeTexture(GLenum texture);
/*! \brief GL function to attach a shader to a program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glAttachShader.xml">
* glAttachShader() OpenGL ES manpage</a>
*/
void attachShader(Program program, Shader shader);
/*! \brief GL function to bind an attribute to a given location
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindAttribLocation.xml">
* glBindAttribLocation() OpenGL ES manpage</a>
*/
void bindAttribLocation(Program program, unsigned index,
const std::string &name);
/*! \brief GL function to bind a buffer to a target
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindBuffer.xml">
* glBindBuffer() OpenGL ES manpage</a>
*/
void bindBuffer(GLenum target, Buffer buffer);
/*! \brief GL function to bind a frame buffer to a target
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindFramebuffer.xml">
* glBindFramebuffer() OpenGL ES manpage</a>
*/
void bindFramebuffer(GLenum target, Framebuffer framebuffer);
/*! \brief GL function to bind a render buffer to a target
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindRenderbuffer.xml">
* glBindRenderbuffer() OpenGL ES manpage</a>
*/
void bindRenderbuffer(GLenum target, Renderbuffer renderbuffer);
/*! \brief GL function to bind a texture to a target
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBindTexture.xml">
* glBindTexture() OpenGL ES manpage</a>
*/
void bindTexture(GLenum target, Texture texture);
/*! \brief GL function to set the blending color
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBlendColor.xml">
* glBlendColor() OpenGL ES manpage</a>
*/
void blendColor(double red, double green, double blue, double alpha);
/*! \brief GL function to set the blending equation
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBlendEquation.xml">
* glBlendEquation() OpenGL ES manpage</a>
*/
void blendEquation(GLenum mode);
/*! \brief GL function that sets separate blending functions for RGB and alpha
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBlendEquationSeparate.xml">
* glBlendEquationSeparate() OpenGL ES manpage</a>
*/
void blendEquationSeparate(GLenum modeRGB, GLenum modeAlpha);
/*! \brief GL function to configure the blending function
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBlendFunc.xml">
* glBlendFunc() OpenGL ES manpage</a>
*/
void blendFunc(GLenum sfactor, GLenum dfactor);
/*! \brief GL function that configures the blending function
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBlendFuncSeparate.xml">
* glBlendFuncSeparate() OpenGL ES manpage</a>
*/
void blendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha);
/*! \brief glBufferData - create and initialize a buffer object's data store
*
* Set the size of the currently bound WebGLBuffer object for the passed target.
* The buffer is initialized to 0.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*/
void bufferData(GLenum target, int size, GLenum usage);
/*! \brief glBufferData - create and initialize a buffer object's data store
* from an ArrayBuffer
*
* Set the size and contents of the currently bound WebGLBuffer object to
* be a copy of the given ArrayBuffer.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*
* Note: an ArrayBuffer refers to a javascript object, which cannot be
* used for server-side rendering. If a server-side fallback will be used,
* then bufferDatafv() should be used with the additional boolean argument to
* indicate binary transfer of the data in case of client-side rendering.
*
* \sa createAndLoadArrayBuffer
*/
void bufferData(GLenum target, ArrayBuffer res, GLenum usage);
/*! \brief glBufferData - create and initialize a buffer object's data store
* from an ArrayBuffer
*
* Set the size of the currently bound WebGLBuffer object to
* arrayBufferSize, and copy the contents of the ArrayBuffer to
* the buffer, starting at the given offset.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*
* Note: not functional for a server-side fall-back (see bufferData(GLenum target, ArrayBuffer res, GLenum usage) for more info)
*
* \sa createAndLoadArrayBuffer
*/
void bufferData(GLenum target, ArrayBuffer res, unsigned arrayBufferOffset,
unsigned arrayBufferSize, GLenum usage);
/*! \brief Initialize a buffer object's data store from an ArrayBuffer
*
* Load the data of the currently bound WebGLBuffer object from
* the given ArrayBuffer. The first byte of the resource data will
* be written at the given offset of the currently bound buffer.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferSubData.xml">
* glBufferSubData() OpenGL ES manpage</a>
*
* Note: not functional for a server-side fall-back (see bufferData(GLenum target, ArrayBuffer res, GLenum usage) for more info)
*
* \sa createAndLoadArrayBuffer
*/
void bufferSubData(GLenum target, unsigned offset, ArrayBuffer res);
/*! \brief Initialize a buffer object's data store from an ArrayBuffer
*
* Load the data of the currently bound WebGLBuffer object from
* the given ArrayBuffer. The byte at position arrayBufferOffset
* will be written to the currently bound buffer at position offset.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferSubData.xml">
* glBufferSubData() OpenGL ES manpage</a>
*
* Note: not functional for a server-side fall-back (see bufferData(GLenum target, ArrayBuffer res, GLenum usage) for more info)
*
* \sa createAndLoadArrayBuffer
*/
void bufferSubData(GLenum target, unsigned offset, ArrayBuffer res,
unsigned arrayBufferOffset, unsigned size);
#if !defined(WT_TARGET_JAVA)
/*! \brief GL function that loads float or double data in a VBO
*
* Unlike the C version, we can't accept a void * here. We must be able
* to interpret the buffer's data in order to transmit it to the JS side.
*
* Later we may also want versions with strides and offsets to cope with
* more complex buffer layouts that we typically see on desktop WebGL apps;
* suggestions to improve this are welcome
*
* Note: prefer bufferDatafv(GLenum target, const std::vector<float> &buffer, GLenum usage, bool binary)
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*/
template<typename Iterator>
void bufferDatafv(GLenum target, const Iterator begin, const Iterator end, GLenum usage, bool binary = false) {
std::vector<float> data;
data.reserve(end-begin);
for (Iterator i = begin; i != end; ++i) {
data.push_back((float)*i);
}
bufferDatafv(target, data, usage, binary);
}
/*! \brief GL function that loads integer data in a VBO
*
* Note: prefer bufferDataiv(GLenum target, std::vector<int> &buffer, GLenum usage, GLenum type)
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*/
template<typename Iterator>
void bufferDataiv(GLenum target, const Iterator begin, const Iterator end,
GLenum usage, GLenum type)
{
std::vector<int> data;
data.reserve(end-begin);
for (Iterator i = begin; i != end; i++)
data.push_back(*i);
bufferDataiv(target, data, usage, type);
}
/*! \brief GL function that updates an existing VBO with new float or double
* data
*
* Note: prefer bufferSubDatafv(GLenum target, unsigned offset, const std::vector<float> &buffer, bool binary)
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferSubData.xml">
* glBufferSubData() OpenGL ES manpage</a>
*/
template<typename Iterator>
void bufferSubDatafv(GLenum target, unsigned offset, const Iterator begin, const Iterator end, bool binary = false)
{
std::vector<float> data;
data.reserve(end-begin);
for (Iterator i = begin; i != end; ++i)
data.push_back(*i);
bufferSubDatafv(target, offset, data, binary);
}
/*! \brief GL function that updates an existing VBO with new integer data
*
* Note: prefer void bufferSubDataiv(GLenum target, unsigned offset, std::vector<int> &buffer, GLenum type)
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glBufferSubData.xml">
* glBufferSubData() OpenGL ES manpage</a>
*/
template<typename Iterator>
void bufferSubDataiv(GLenum target, unsigned offset, const Iterator begin, Iterator end, GLenum type)
{
std::vector<int> data;
data.reserve(end-begin);
for (Iterator i = begin; i != end; i++)
data.push_back(*i);
bufferSubDataiv(target, offset, data, type);
}
#endif
/*! \brief GL function that loads float or double data in a VBO
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*/
#ifdef WT_TARGET_JAVA
void bufferDatafv(GLenum target, const FloatBuffer &buffer, GLenum usage, bool binary = false);
void bufferDatafv(GLenum target, const FloatNotByteBuffer &buffer, GLenum usage);
#else
void bufferDatafv(GLenum target, const std::vector<float> &buffer, GLenum usage, bool binary = false);
#endif
/*! \brief remove all binary buffer resources
*
* Removes all WMemoryResources that were allocated when calling
* bufferDatafv with binary=true. This is not required, since the resources
* are also managed, but if you are sure they will not be used anymore in
* the client, this can help free some memory.
*/
void clearBinaryResources();
/*! \brief GL function that updates an existing VBO with new integer data
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/glBufferData.xml">
* glBufferData() OpenGL ES manpage</a>
*/
#ifdef WT_TARGET_JAVA
void bufferDataiv(GLenum target, IntBuffer &buffer, GLenum usage,
GLenum type);
#else
void bufferDataiv(GLenum target, std::vector<int> &buffer, GLenum usage,
GLenum type);
#endif
/*! \brief GL function that updates an existing VBO with new float data
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/glBufferSubData.xml">
* glBufferSubData() OpenGL ES manpage</a>
*/
#ifdef WT_TARGET_JAVA
void bufferSubDatafv(GLenum target, unsigned offset,
const FloatBuffer &buffer, bool binary = false);
void bufferSubDatafv(GLenum target, unsigned offset,
const FloatNotByteBuffer &buffer);
#else
void bufferSubDatafv(GLenum target, unsigned offset,
const std::vector<float> &buffer, bool binary = false);
#endif
/*! \brief GL function that loads integer data in a VBO
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/glBufferSubData.xml">
* glBufferSubData() OpenGL ES manpage</a>
*/
#ifdef WT_TARGET_JAVA
void bufferSubDataiv(GLenum target,
unsigned offset, IntBuffer &buffer,
GLenum type);
#else
void bufferSubDataiv(GLenum target,
unsigned offset, std::vector<int> &buffer,
GLenum type);
#endif
//GLenum checkFramebufferStatus(GLenum target);
/*! \brief GL function that clears the given buffers
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glClear.xml">
* glClear() OpenGL ES manpage</a>
*/
void clear(WFlags<GLenum> mask);
/*! \brief GL function that sets the clear color of the color buffer
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glClearColor.xml">
* glClearColor() OpenGL ES manpage</a>
*/
void clearColor(double r, double g, double b, double a);
/*! \brief GL function that configures the depth to be set when the
* depth buffer is cleared
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glClearDepthf.xml">
* glClearDepthf() OpenGL ES manpage</a>
*/
void clearDepth(double depth);
/*! \brief GL function
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glClearStencil.xml">
* glClearStencil() OpenGL ES manpage</a>
*/
void clearStencil(int s);
/*! \brief GL function
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glColorMask.xml">
* glColorMask() OpenGL ES manpage</a>
*/
void colorMask(bool red, bool green, bool blue, bool alpha);
/*! \brief GL function to compile a shader
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCompileShader.xml">
* glCompileShader() OpenGL ES manpage</a>
*/
void compileShader(Shader shader);
/*! \brief GL function to copy a texture image
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCopyTexImage2D.xml">
* glCopyTexImage2D() OpenGL ES manpage</a>
*/
void copyTexImage2D(GLenum target, int level,
GLenum internalformat,
int x, int y,
unsigned width, unsigned height,
int border);
/*! \brief GL function that copies a part of a texture image
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCopyTexSubImage2D.xml">
* glCopyTexSubImage2D() OpenGL ES manpage</a>
*/
void copyTexSubImage2D(GLenum target, int level,
int xoffset, int yoffset,
int x, int y,
unsigned width, unsigned height);
/*! \brief GL function that creates an empty VBO
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenBuffers.xml">
* glGenBuffers() OpenGL ES manpage</a>
*/
Buffer createBuffer();
/*! \brief Function that creates an ArrayBuffer by loading data from
* a given URL. (<b>deprecated</b>)
*
* The ArrayBuffer is loaded before executing initGL.
* Use it to load binary data for use in bufferData() or bufferSubData().
*
* \deprecated An ArrayBuffer refers to a javascript object, which cannot be
* used for server-side rendering. The new way to accomplish a binary transfer
* of buffers is with the added boolean argument in bufferSubDatafv()
*/
ArrayBuffer createAndLoadArrayBuffer(const std::string &url);
/*! \brief GL function that creates a frame buffer object
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenFramebuffers.xml">
* glGenFramebuffers() OpenGL ES manpage</a>
*/
Framebuffer createFramebuffer();
/*! \brief GL function that creates an empty program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCreateProgram.xml">
* glCreateProgram() OpenGL ES manpage</a>
*/
Program createProgram();
/*! \brief GL function that creates a render buffer object
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenRenderbuffers.xml">
* glGenRenderbuffers() OpenGL ES manpage</a>
*/
Renderbuffer createRenderbuffer();
/*! \brief GL function that creates an empty shader
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCreateShader.xml">
* glCreateShader() OpenGL ES manpage</a>
*/
Shader createShader(GLenum shader);
/*! \brief GL function that creates an empty texture
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenTextures.xml">
* glGenTextures() OpenGL ES manpage</a>
*/
Texture createTexture();
/*! \brief GL function that creates an image texture
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenTextures.xml">
* glGenTextures() OpenGL ES manpage</a>
*/
Texture createTextureAndLoad(const std::string &url);
/*! \brief returns an paintdevice that can be used to paint a GL texture
*
* If the client has a webGL enabled browser this function returns a
* WCanvasPaintDevice. If server-side rendering is used as fallback then
* this function returns a WRasterImage
*/
WPaintDevice *createPaintDevice(const WLength& width,
const WLength& height);
/*! \brief GL function that configures the backface culling mode
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glCullFace.xml">
* glCullFace() OpenGL ES manpage</a>
*/
void cullFace(GLenum mode);
/*! \brief GL function that deletes a VBO
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteBuffers.xml">
* glDeleteBuffers() OpenGL ES manpage</a>
*/
void deleteBuffer(Buffer buffer);
/*! \brief GL function that deletes a frame buffer
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteFramebuffers.xml">
* glDeleteFramebuffers() OpenGL ES manpage</a>
*/
void deleteFramebuffer(Framebuffer framebuffer);
/*! \brief GL function that deletes a program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteProgram.xml">
* glDeleteProgram() OpenGL ES manpage</a>
*/
void deleteProgram(Program program);
/*! \brief GL function that deletes a render buffer
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteRenderbuffers.xml">
* glDeleteRenderbuffers() OpenGL ES manpage</a>
*/
void deleteRenderbuffer(Renderbuffer renderbuffer);
/*! \brief GL function that depetes a shader
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteShader.xml">
* glDeleteShader() OpenGL ES manpage</a>
*/
void deleteShader(Shader shader);
/*! \brief GL function that deletes a texture
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDeleteTextures.xml">
* glDeleteTextures() OpenGL ES manpage</a>
*/
void deleteTexture(Texture texture);
/*! \brief GL function to set the depth test function
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDepthFunc.xml">
* glDepthFunc() OpenGL ES manpage</a>
*/
void depthFunc(GLenum func);
/*! \brief GL function that enables or disables writing to the depth buffer
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDepthMask.xml">
* glDepthMask() OpenGL ES manpage</a>
*/
void depthMask(bool flag);
/*! \brief GL function that specifies to what range the normalized [-1,1] z
* values should match.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDepthRangef.xml">
* glDepthRangef() OpenGL ES manpage</a>
*/
void depthRange(double zNear, double zFar);
/*! \brief GL function that detaches a shader from a program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDetachShader.xml">
* glDetachShader() OpenGL ES manpage</a>
*/
void detachShader(Program program, Shader shader);
/*! \brief GL function to disable features
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDisable.xml">
* glDisable() OpenGL ES manpage</a>
*/
void disable(GLenum cap);
/*! \brief GL function to disable the vertex attribute array
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDisableVertexAttribArray.xml">
* glDisableVertexAttribArray() OpenGL ES manpage</a>
*/
void disableVertexAttribArray(AttribLocation index);
/*! \brief GL function to draw a VBO
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDrawArrays.xml">
* glDrawArrays() OpenGL ES manpage</a>
*/
void drawArrays(GLenum mode, int first, unsigned count);
/*! \brief GL function to draw indexed VBOs
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glDrawElements.xml">
* glDrawElements() OpenGL ES manpage</a>
*/
void drawElements(GLenum mode, unsigned count, GLenum type, unsigned offset);
/*! \brief GL function to enable features
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glEnable.xml">
* glEnable() OpenGL ES manpage</a>
*/
void enable(GLenum cap);
/*! \brief GL function to enable the vertex attribute array
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glEnableVertexAttribArray.xml">
* glEnableVertexAttribArray() OpenGL ES manpage</a>
*/
void enableVertexAttribArray(AttribLocation index);
/*! \brief GL function to wait until given commands are executed
*
* This call is transfered to JS, but the server will never wait on
* this call.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFinish.xml">
* glFinish() OpenGL ES manpage</a>
*/
void finish();
/*! \brief GL function to force execution of GL commands in finite time.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFlush.xml">
* glFlush() OpenGL ES manpage</a>
*/
void flush();
/*! \brief GL function to attach the given renderbuffer to the currently
* bound frame buffer.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFramebufferRenderbuffer.xml">
* glFramebufferRenderbuffer() OpenGL ES manpage</a>
*/
void framebufferRenderbuffer(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
Renderbuffer renderbuffer);
/*! \brief GL function to render directly into a texture image.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFramebufferTexture2D.xml">
* glFramebufferTexture2D() OpenGL ES manpage</a>
*/
void framebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget,
Texture texture, int level);
/*! \brief GL function that specifies which side of a triangle is the
* front side
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glFrontFace.xml">
* glFrontFace() OpenGL ES manpage</a>
*/
void frontFace(GLenum mode);
/*! \brief GL function that generates a set of mipmaps for a texture
* object.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGenerateMipmap.xml">
* glGenerateMipmap() OpenGL ES manpage</a>
*/
void generateMipmap(GLenum target);
//WebGLActiveInfo getActiveAttrib(WebGLProgram program, GLuint index);
//WebGLActiveInfo getActiveUniform(WebGLProgram program, GLuint index);
//WebGLShader[ ] getAttachedShaders(WebGLProgram program);
/*! \brief GL function to retrieve an attribute's location in a Program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetAttribLocation.xml">
* glGetAttribLocation() OpenGL ES manpage</a>
*/
AttribLocation getAttribLocation(Program program, const std::string &attrib);
//any getParameter(GLenum pname);
//any getBufferParameter(GLenum target, GLenum pname);
//GLenum getError();
//any getFramebufferAttachmentParameter(GLenum target, GLenum attachment,
// GLenum pname);
//any getProgramParameter(WebGLProgram program, GLenum pname);
//DOMString getProgramInfoLog(WebGLProgram program);
//any getRenderbufferParameter(GLenum target, GLenum pname);
//any getShaderParameter(WebGLShader shader, GLenum pname);
//DOMString getShaderInfoLog(WebGLShader shader);
//DOMString getShaderSource(WebGLShader shader);
//any getTexParameter(GLenum target, GLenum pname);
//any getUniform(WebGLProgram program, WebGLUniformLocation location);
/*! \brief GL function to retrieve a Uniform's location in a Program.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glGetUniformLocation.xml">
* glGetUniformLocation() OpenGL ES manpage</a>
*/
UniformLocation getUniformLocation(Program program, const std::string location);
//any getVertexAttrib(GLuint index, GLenum pname);
//GLsizeiptr getVertexAttribOffset(GLuint index, GLenum pname);
/*! \brief GL function to give hints to the render pipeline
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glHint.xml">
* glHint() OpenGL ES manpage</a>
*/
void hint(GLenum target, GLenum mode);
//GLboolean isBuffer(WebGLBuffer buffer);
//GLboolean isEnabled(GLenum cap);
//GLboolean isFramebuffer(WebGLFramebuffer framebuffer);
//GLboolean isProgram(WebGLProgram program);
//GLboolean isRenderbuffer(WebGLRenderbuffer renderbuffer);
//GLboolean isShader(WebGLShader shader);
//GLboolean isTexture(WebGLTexture texture);
/*! \brief GL function to set the line width
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glLineWidth.xml">
* glLineWidth() OpenGL ES manpage</a>
*/
void lineWidth(double width);
/*! \brief GL function to link a program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glLinkProgram.xml">
* glLinkProgram() OpenGL ES manpage</a>
*/
void linkProgram(Program program);
/*! \brief GL function to set the pixel storage mode
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glPixelStorei.xml">
* glPixelStorei() OpenGL ES manpage</a>
*/
void pixelStorei(GLenum pname, int param);
/*! \brief GL function to apply modifications to Z values
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glPolygonOffset.xml">
* glPolygonOffset() OpenGL ES manpage</a>
*/
void polygonOffset(double factor, double units);
//void readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
// GLenum format, GLenum type, ArrayBufferView pixels);
/*! \brief GL function to allocate the appropriate amount of memory for
* a render buffer
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glRenderbufferStorage.xml">
* glSampleCoverage() OpenGL ES manpage</a>
*/
void renderbufferStorage(GLenum target, GLenum internalformat,
unsigned width, unsigned height);
/*! \brief GL function to set multisample parameters
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glSampleCoverage.xml">
* glSampleCoverage() OpenGL ES manpage</a>
*/
void sampleCoverage(double value, bool invert);
/*! \brief GL function to define the scissor box
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glScissor.xml">
* glScissor() OpenGL ES manpage</a>
*/
void scissor(int x, int y, unsigned width, unsigned height);
/*! \brief GL function to set a shader's source code
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glShaderSource.xml">
* glShaderSource() OpenGL ES manpage</a>
*/
void shaderSource(Shader shader, const std::string &src);
/*! \brief GL function to set stencil test parameters
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glStencilFunc.xml">
* glStencilFunc() OpenGL ES manpage</a>
*/
void stencilFunc(GLenum func, int ref, unsigned mask);
/*! \brief GL function to set stencil test parameters for front and/or
* back stencils
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glStencilFuncSeparate.xml">
* glStencilFuncSeparate() OpenGL ES manpage</a>
*/
void stencilFuncSeparate(GLenum face, GLenum func, int ref, unsigned mask);
/*! \brief GL function to control which bits are to be written in the stencil
* buffer
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glStencilMask.xml">
* glStencilMask() OpenGL ES manpage</a>
*/
void stencilMask(unsigned mask);
/*! \brief GL function to control which bits are written to the front and/or
* back stencil buffers
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glStencilMaskSeparate.xml">
* glStencilMaskSeparate() OpenGL ES manpage</a>
*/
void stencilMaskSeparate(GLenum face, unsigned mask);
/*! \brief GL function to set stencil test actions
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glStencilOp.xml">
* glStencilOp() OpenGL ES manpage</a>
*/
void stencilOp(GLenum fail, GLenum zfail, GLenum zpass);
/*! \brief GL function to set front and/or back stencil test actions
* separately
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glStencilOpSeparate.xml">
* glStencilOpSeparate() OpenGL ES manpage</a>
*/
void stencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
//void texImage2D(TextureTargetEnum target, int level, PixelFormatEnum internalformat,
// GLsizei width, GLsizei height, GLint border, PixelFormatEnum format,
// GLenum type, ArrayBufferView pixels);
/*! \brief GL function to reserve space for a 2D texture, without specifying its
* contents.
*
* This corresponds to calling the WebGL function
* void texImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width,
* GLsizei height, GLint border, GLenum format, GLenum type, ArrayBufferView pixels)
* with null as last parameters. The value of 'type' is then of no importance and is
* therefore omitted from this function.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexImage2D.xml">
* glTexImage2D() OpenGL ES manpage</a>
*/
void texImage2D(GLenum target, int level, GLenum internalformat,
unsigned width, unsigned height, int border, GLenum format);
//void texImage2D(TextureTargetEnum target, int level, PixelFormatEnum internalformat,
// PixelFormatEnum format, GLenum type, ImageData pixels);
/*! \brief GL function to load a 2D texture from a WImage
*
* Note: WImage must be loaded before this function is executed.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexImage2D.xml">
* glTexImage2D() OpenGL ES manpage</a>
*/
void texImage2D(GLenum target, int level, GLenum internalformat,
GLenum format, GLenum type, WImage *image);
//void texImage2D(TextureTargetEnum target, int level, PixelFormatEnum internalformat,
// PixelFormatEnum format, GLenum type, HTMLCanvasElement canvas);
/*! \brief GL function to load a 2D texture from a WVideo
*
* Note: the video must be loaded prior to calling this function. The
* current frame is used as texture image.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexImage2D.xml">
* glTexImage2D() OpenGL ES manpage</a>
*/
void texImage2D(GLenum target, int level, GLenum internalformat,
GLenum format, GLenum type, WVideo *video);
/*! \brief GL function to load a 2D texture from a file
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexImage2D.xml">
* glTexImage2D() OpenGL ES manpage</a>
*/
void texImage2D(GLenum target, int level, GLenum internalformat,
GLenum format, GLenum type, std::string filename);
/*! \brief GL function to load a 2D texture from a WPaintDevice
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexImage2D.xml">
* glTexImage2D() OpenGL ES manpage</a>
*
* \sa createPaintDevice()
*/
void texImage2D(GLenum target, int level, GLenum internalformat,
GLenum format, GLenum type, WPaintDevice *paintdevice);
/*! \brief GL function to load a 2D texture loaded with createTextureAndLoad()
*
* This function must only be used for textures created with
* createTextureAndLoad()
*
* Note: the WGLWidget implementation will delay rendering until
* all textures created with createTextureAndLoad() are loaded in the
* browser.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexImage2D.xml">
* glTexImage2D() OpenGL ES manpage</a>
*/
void texImage2D(GLenum target, int level, GLenum internalformat,
GLenum format, GLenum type, Texture texture);
//void texParameterf(TextureTargetEnum target,
// TextureParameterNameEnum pname, double param);
/*! \brief GL function to set texture parameters
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glTexParameter.xml">
* glTexParameter() OpenGL ES manpage</a>
*/
void texParameteri(GLenum target, GLenum pname, GLenum param);
//void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
// GLsizei width, GLsizei height,
// GLenum format, GLenum type, ArrayBufferView pixels);
//void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
// GLenum format, GLenum type, ImageData pixels);
//void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
// GLenum format, GLenum type, HTMLImageElement image);
//void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
// GLenum format, GLenum type, HTMLCanvasElement canvas);
//void texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
// GLenum format, GLenum type, HTMLVideoElement video);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform1f(const UniformLocation &location, double x);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void uniform1fv(const UniformLocation &location,
const WT_ARRAY FloatArray *value)
#ifndef WT_TARGET_JAVA
{
float out[1];
for (int i=0; i<1; i++) {
out[i] = (float)value[i];
}
uniform1fv(location, out);
}
/// \cond
void uniform1fv(const UniformLocation &location,
const WT_ARRAY float *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform1i(const UniformLocation &location, int x);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename IntArray)
void uniform1iv(const UniformLocation &location,
const WT_ARRAY IntArray *value)
#ifndef WT_TARGET_JAVA
{
int out[1];
for (int i=0; i<1; i++) {
out[i] = (int)value[i];
}
uniform1iv(location, out);
}
/// \cond
void uniform1iv(const UniformLocation &location,
const WT_ARRAY int *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform2f(const UniformLocation &location, double x, double y);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void uniform2fv(const UniformLocation &location,
const WT_ARRAY FloatArray *value)
#ifndef WT_TARGET_JAVA
{
float out[2];
for (int i=0; i<2; i++) {
out[i] = (float)value[i];
}
uniform2fv(location, out);
}
/// \cond
void uniform2fv(const UniformLocation &location,
const WT_ARRAY float *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform2i(const UniformLocation &location, int x, int y);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename IntArray)
void uniform2iv(const UniformLocation &location,
const WT_ARRAY IntArray *value)
#ifndef WT_TARGET_JAVA
{
int out[2];
for (int i=0; i<2; i++) {
out[i] = (int)value[i];
}
uniform2iv(location, out);
}
/// \cond
void uniform2iv(const UniformLocation &location,
const WT_ARRAY int *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform3f(const UniformLocation &location,
double x, double y, double z);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void uniform3fv(const UniformLocation &location,
const WT_ARRAY FloatArray *value)
#ifndef WT_TARGET_JAVA
{
float out[3];
for (int i=0; i<3; i++) {
out[i] = (float)value[i];
}
uniform3fv(location, out);
}
/// \cond
void uniform3fv(const UniformLocation &location,
const WT_ARRAY float *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform3i(const UniformLocation &location, int x, int y, int z);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename IntArray)
void uniform3iv(const UniformLocation &location,
const WT_ARRAY IntArray *value)
#ifndef WT_TARGET_JAVA
{
int out[3];
for (int i=0; i<3; i++) {
out[i] = (int)value[i];
}
uniform3iv(location, out);
}
/// \cond
void uniform3iv(const UniformLocation &location,
const WT_ARRAY int *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform4f(const UniformLocation &location,
double x, double y, double z, double w);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void uniform4fv(const UniformLocation &location,
const WT_ARRAY FloatArray *value)
#ifndef WT_TARGET_JAVA
{
float out[4];
for (int i=0; i<4; i++) {
out[i] = (float)value[i];
}
uniform4fv(location, out);
}
/// \cond
void uniform4fv(const UniformLocation &location,
const WT_ARRAY float *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniform4i(const UniformLocation &location, int x, int y, int z, int w);
/*! \brief GL function to set the value of a uniform variable of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename IntArray)
void uniform4iv(const UniformLocation &location,
const WT_ARRAY IntArray *value)
#ifndef WT_TARGET_JAVA
{
int out[4];
for (int i=0; i<4; i++) {
out[i] = (int)value[i];
}
uniform4iv(location, out);
}
/// \cond
void uniform4iv(const UniformLocation &location,
const WT_ARRAY int *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* Attention: The OpenGL ES specification states that transpose MUST be
* false.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename MatrixType)
void uniformMatrix2fv(const UniformLocation &location,
bool transpose,
const WT_ARRAY MatrixType *value)
#ifndef WT_TARGET_JAVA
{
double out[4];
for (int i=0; i<4; i++) {
out[i] = (double)value[i];
}
uniformMatrix2fv(location, transpose, out);
}
/// \cond
void uniformMatrix2fv(const UniformLocation &location,
bool transpose,
const WT_ARRAY double *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* This function renders the matrix in the proper row/column order.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename MatrixType)
void uniformMatrix2(const UniformLocation &location,
const WGenericMatrix<MatrixType, 2, 2> &m)
#ifndef WT_TARGET_JAVA
{
WGenericMatrix<double, 2, 2> out;
for (int i=0; i<2; i++) {
for (int j=0; j<2; j++) {
out.at(i, j) = (double)m.at(i, j);
}
}
uniformMatrix2(location, out);
}
/// \cond
void uniformMatrix2(const UniformLocation &location,
const WGenericMatrix<double, 2, 2> &m);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* Attention: The OpenGL ES specification states that transpose MUST be
* false.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename MatrixType)
void uniformMatrix3fv(const UniformLocation &location, bool transpose,
const WT_ARRAY MatrixType *value)
#ifndef WT_TARGET_JAVA
{
double out[9];
for (int i=0; i<9; i++) {
out[i] = (double)value[i];
}
uniformMatrix3fv(location, transpose, out);
}
/// \cond
void uniformMatrix3fv(const UniformLocation &location, bool transpose,
const WT_ARRAY double *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* This function renders the matrix in the proper row/column order.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename MatrixType)
void uniformMatrix3(const UniformLocation &location,
const WGenericMatrix<MatrixType, 3, 3> &m)
#ifndef WT_TARGET_JAVA
{
WGenericMatrix<double, 3, 3> out;
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
out.at(i, j) = (double)m.at(i, j);
}
}
uniformMatrix3(location, out);
}
/// \cond
void uniformMatrix3(const UniformLocation &location,
const WGenericMatrix<double, 3, 3> &m);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* Attention: The OpenGL ES specification states that transpose MUST be
* false.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename MatrixType)
void uniformMatrix4fv(const UniformLocation &location, bool transpose,
const WT_ARRAY MatrixType *value)
#ifndef WT_TARGET_JAVA
{
double out[16];
for (int i=0; i<16; i++) {
out[i] = (double)value[i];
}
uniformMatrix4fv(location, transpose, out);
}
/// \cond
void uniformMatrix4fv(const UniformLocation &location, bool transpose,
const WT_ARRAY double *value);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* This function renders the matrix in the proper row/column order.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename MatrixType)
void uniformMatrix4(const UniformLocation &location,
const WGenericMatrix<MatrixType, 4, 4> &m)
#ifndef WT_TARGET_JAVA
{
WGenericMatrix<double, 4, 4> out;
for (int i=0; i<4; i++) {
for (int j=0; j<4; j++) {
out.at(i, j) = (double)m.at(i, j);
}
}
uniformMatrix4(location, out);
}
/// \cond
void uniformMatrix4(const UniformLocation &location,
const WGenericMatrix<double, 4, 4> &m);
/// \endcond
#else
;
#endif
/*! \brief GL function to set the value of a uniform matrix of the current
* program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUniform.xml">
* glUniform() OpenGL ES manpage</a>
*/
void uniformMatrix4(const UniformLocation &location,
const JavaScriptMatrix4x4 &m);
/*! \brief GL function to set the current active shader program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glUseProgram.xml">
* glUseProgram() OpenGL ES manpage</a>
*/
void useProgram(Program program);
/*! \brief GL function to validate a program
*
* implementation note: there is currently not yet a method to read
* out the validation result.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glValidateProgram.xml">
* glValidateProgram() OpenGL ES manpage</a>
*/
void validateProgram(Program program);
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
void vertexAttrib1f(AttribLocation location, double x);
#ifndef WT_TARGET_JAVA
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void vertexAttrib1fv(AttribLocation location,
const WT_ARRAY FloatArray *values) {
vertexAttrib1f(location, values[0]);
}
#endif
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
void vertexAttrib2f(AttribLocation location, double x, double y);
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void vertexAttrib2fv(AttribLocation location,
const WT_ARRAY FloatArray *values) {
vertexAttrib2f(location, values[0], values[1]);
}
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
void vertexAttrib3f(AttribLocation location, double x, double y, double z);
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void vertexAttrib3fv(AttribLocation location,
const WT_ARRAY FloatArray *values) {
vertexAttrib3f(location, values[0], values[1], values[2]);
}
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
void vertexAttrib4f(AttribLocation location,
double x, double y, double z, double w);
/*! \brief GL function to set the value of an attribute of the current program
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttrib.xml">
* glVertexAttrib() OpenGL ES manpage</a>
*/
WT_WGL_TEMPLATE(typename FloatArray)
void vertexAttrib4fv(AttribLocation location,
const WT_ARRAY FloatArray *values) {
vertexAttrib4f(location, values[0], values[1], values[2], values[3]);
}
/*! \brief GL function to bind a VBO to an attribute
*
* This function links the given attribute to the VBO currently bound
* to the ARRAY_BUFFER target.
*
* The size parameter specifies the number of components per attribute (1
* to 4). The type parameter is also used to determine the size of each
* component.
*
* The size of a float is 8 bytes.
*
* In WGLWidget, the size of an int is 4 bytes.
*
* The stride is in bytes.
*
* The maximum stride is 255.
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glVertexAttribPointer.xml">
* glVertexAttribPointer() OpenGL ES manpage</a>
*/
void vertexAttribPointer(AttribLocation location, int size,
GLenum type, bool normalized, unsigned stride, unsigned offset);
/*! \brief GL function to set the viewport
*
* <a href="http://www.khronos.org/opengles/sdk/2.0/docs/man/xhtml/glViewport.xml">
* glViewport() OpenGL ES manpage</a>
*/
void viewport(int x, int y, unsigned width, unsigned height);
/*! @}
*/
/*! @name Additional WebGL methods
*
* These methods are used to render WebGL content, but have no equivalent
* in WebGL.
*
* Like the WebGL methods, you can use the WebGL methods in your resizeGL(),
* paintGL() and updateGL() specializations. It makes no sense to call these
* methods outside those functions.
* @{
*/
/*! \brief Create a matrix that can be manipulated in client-side
* JavaScript
*/
JavaScriptMatrix4x4 createJavaScriptMatrix4();
/*! \brief Set the value of a client-side JavaScript matrix created by
* createJavaScriptMatrix4x4()
*/
WT_WGL_TEMPLATE(typename MatrixType)
void setJavaScriptMatrix4(JavaScriptMatrix4x4 &jsm,
const WGenericMatrix<MatrixType, 4, 4> &m)
#ifndef WT_TARGET_JAVA
{
WGenericMatrix<double, 4, 4> out;
for (int i=0; i<4; i++) {
for (int j=0; j<4; j++) {
out.at(i, j) = (double)m.at(i, j);
}
}
setJavaScriptMatrix4(jsm, out);
}
/// \cond
void setJavaScriptMatrix4(JavaScriptMatrix4x4 &jsm,
const WGenericMatrix<double, 4, 4> &m);
/// \endcond
#else
;
#endif
/*! @}
*/
// Todo:
// Get the current client-side value of a JavaScriptMatrix
//WMatrix4x4 getJavaScriptMatrix4();
/*! \brief Add a mouse handler to the widget that looks at a given point
*
* This will allow a user to change client-side matrix m with the
* mouse. M is a model transformation matrix, representing the viewpoint of
* the camera.
*
* Through mouse operations, the camera can be changed by the user, but
* (lX, lY, lZ) will always be at the center of the display, (uX, uY, uZ)
* is considered to be the up direction, and the distance of the camera to
* (lX, lY, lZ) will never change.
*
* Pressing the left mouse button and moving the mouse left/right will
* rotate the camera around the up (uX, uY, uZ) direction. Moving up/down
* will tilt the camera (causing it to move up/down to keep the lookpoint
* centered). The scroll wheel simulates zooming by scaling the scene.
*
* pitchRate and yawRate control how much the camera will move per mouse
* pixel.
*
* Usually this method is called after setting a camera transformation
* with a client-side matrix in initializeGL(). However, this function
* may also be called from outside the intializeGL()/paintGL()/updateGL()
* methods (but not before m was initialized).
*/
void setClientSideLookAtHandler(const JavaScriptMatrix4x4 &m,
double lX, double lY, double lZ,
double uX, double uY, double uZ,
double pitchRate, double yawRate);
/*! \brief Add a mouse handler to the widget that allows 'walking' in
* the scene
*
* This will allow a user to change client-side matrix m with the
* mouse. M is a model transformation matrix, representing the viewpoint of
* the camera.
*
* Through mouse operations, the camera can be changed by the user, as if
* he is walking around on a plane.
*
* Pressing the left mouse button and moving the mouse left/right will
* rotate the camera around Y axis. Moving the mouse up/down will move
* the camera in the Z direction (walking forward/backward).
* centered).
*
* frontStep and rotStep control how much the camera will move per mouse
* pixel.
*
* Usually this method is called after setting a camera transformation
* with a client-side matrix in initializeGL(). However, this function
* may also be called from outside the intializeGL()/paintGL()/updateGL()
* methods (but not before m was initialized).
*/
void setClientSideWalkHandler(const JavaScriptMatrix4x4 &m,
double frontStep, double rotStep);
/*! \brief Sets the content to be displayed when WebGL is not available.
*
* If Wt cannot create a working WebGL context, this content will be
* shown to the user. This may be a text explanation, or a pre-rendered
* image, or a video, a flash movie, ...
*
* The default is a widget that explains to the user that he has no
* WebGL support.
*/
void setAlternativeContent(WWidget *alternative);
/*! \brief Return whether the alternative content is shown.
*
* If the alternative content is being rendered on the user's screen, this
* function will return true. This is the case is the browser does not have
* WebGL support and the server-side fallback failed (or is not present).
*/
bool isAlternative();
/*! \brief A JavaScript slot that repaints the widget when triggered.
*
* This is useful for client-side initiated repaints. You may e.g. use this
* if you write your own client-side mouse handler, or if you updated
* a texture, or if you're playing a video texture.
*/
JSlot &repaintSlot() { return repaintSlot_; }
/*! \brief enable client-side error messages (read detailed doc!)
*
* This option will add client-side code to check the result of every
* WebGL call, and will popup an error dialog if a WebGL call returned
* an error. The JavaScript then invokes the client-side debugger. This
* code is intended to test your application, and should not be used in
* production.
*
* Note that this option will not have any effect unless both Wt and your
* application is built with WT_WGLWIDGET_DEBUG defined.
*/
void enableClientErrorChecks(bool enable = true);
/*! \brief Inject JavaScript into the current js-stream.
*
* Careful: this method directly puts the given jsString into
* the JavaScript stream, whatever state it current has.
* For example, if called in initGL(), it will put the jsString
* into the client-side initGL() code.
*/
void injectJS(const std::string & jsString);
void webglNotAvailable();
bool isWebGLAvailable() { return webGlNotAvailable_; }
protected:
virtual DomElementType domElementType() const;
virtual DomElement *createDomElement(WApplication *app);
virtual void getDomChanges(std::vector<DomElement *>& result, WApplication *app);
virtual void updateDom(DomElement &element, bool all);
virtual void render(WFlags<RenderFlag> flags);
virtual std::string renderRemoveJs();
virtual void layoutSizeChanged(int width, int height);
virtual void setFormData(const FormData& formData);
private:
WFlags<RenderOption> renderOptions_;
WAbstractGLImplementation *pImpl_;
struct jsMatrixMap {
int id;
WMatrix4x4 serverSideCopy;
jsMatrixMap(int matId, const WMatrix4x4& ssCopy)
: id(matId), serverSideCopy(ssCopy)
{}
};
std::vector<jsMatrixMap> jsMatrixList_;
JSignal<> repaintSignal_;
std::string glObjJsRef();
WWidget *alternative_;
// If client detects that a WebGL context cannot be created, it fires this
// signal, and the handler sets wegGlNotAvailable_ to true. If this happens,
// the client side will have deleted the canvas widget.
JSignal<void> webglNotAvailable_;
bool webGlNotAvailable_;
JSlot mouseWentDownSlot_;
JSlot mouseWentUpSlot_;
JSlot mouseDraggedSlot_;
JSlot mouseWheelSlot_;
JSlot touchStarted_;
JSlot touchEnded_;
JSlot touchMoved_;
JSlot repaintSlot_;
void defineJavaScript();
#ifdef WT_TARGET_JAVA
static void renderfv(std::ostream &os, WGenericMatrix<MatrixType, 4, 4> t,
JsArrayType type);
#endif
friend class WGLWidget::JavaScriptMatrix4x4;
};
W_DECLARE_OPERATORS_FOR_FLAGS(WGLWidget::GLenum)
W_DECLARE_OPERATORS_FOR_FLAGS(WGLWidget::ClientSideRenderer)
W_DECLARE_OPERATORS_FOR_FLAGS(WGLWidget::RenderOption)
}
#undef WT_WGL_TEMPLATE
#endif
|