Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
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 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634
diff --git a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj
index 4ef300a..1fd5189 100644
--- a/VisualC/tests/loopwave/loopwave_VS2010.vcxproj
+++ b/VisualC/tests/loopwave/loopwave_VS2010.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -105,7 +105,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
@@ -139,7 +140,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
@@ -174,7 +176,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
@@ -208,7 +211,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
diff --git a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj
index 0a64859..ea983c5 100644
--- a/VisualC/tests/loopwave/loopwave_VS2012.vcxproj
+++ b/VisualC/tests/loopwave/loopwave_VS2012.vcxproj
@@ -109,7 +109,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
@@ -143,7 +144,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
@@ -178,7 +180,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
@@ -212,7 +215,8 @@
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
- <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"</Command>
+ <Command>copy "$(SolutionDir)\SDL\$(Platform)\$(Configuration)\SDL2.dll" "$(TargetDir)\SDL2.dll"
+copy "$(SolutionDir)\..\test\sample.wav" "$(TargetDir)\sample.wav"</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy SDL</Message>
diff --git a/test/checkkeys.c b/test/checkkeys.c
index 61e8be0..5f2d148 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -117,13 +117,13 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
static void
PrintText(char *text)
{
- unsigned char *spot, expanded[1024];
+ char *spot, expanded[1024];
expanded[0] = '\0';
for ( spot = text; *spot; ++spot )
{
size_t length = SDL_strlen(expanded);
- SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", *spot);
+ SDL_snprintf(expanded + length, sizeof(expanded) - length, "\\x%.2x", (unsigned char)*spot);
}
SDL_Log("Text (%s): \"%s%s\"\n", expanded, *text == '"' ? "\\" : "", text);
}
@@ -134,10 +134,13 @@ main(int argc, char *argv[])
SDL_Window *window;
SDL_Event event;
int done;
+
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Initialize SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
@@ -146,7 +149,7 @@ main(int argc, char *argv[])
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, 0);
if (!window) {
- fprintf(stderr, "Couldn't create 640x480 window: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n",
SDL_GetError());
quit(2);
}
@@ -166,7 +169,7 @@ main(int argc, char *argv[])
switch (event.type) {
case SDL_KEYDOWN:
case SDL_KEYUP:
- PrintKey(&event.key.keysym, event.key.state, event.key.repeat);
+ PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
break;
case SDL_TEXTINPUT:
PrintText(event.text.text);
diff --git a/test/loopwave.c b/test/loopwave.c
index 22b0559..34d07c2 100644
--- a/test/loopwave.c
+++ b/test/loopwave.c
@@ -80,9 +80,12 @@ main(int argc, char *argv[])
{
int i;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
@@ -91,7 +94,7 @@ main(int argc, char *argv[])
}
/* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) {
- fprintf(stderr, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError());
quit(1);
}
@@ -109,24 +112,19 @@ main(int argc, char *argv[])
#endif /* HAVE_SIGNAL_H */
/* Show the list of available drivers */
- printf("Available audio drivers: ");
+ SDL_Log("Available audio drivers:");
for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
- if (i == 0) {
- printf("%s", SDL_GetAudioDriver(i));
- } else {
- printf(", %s", SDL_GetAudioDriver(i));
- }
+ SDL_Log("%i: %s", i, SDL_GetAudioDriver(i));
}
- printf("\n");
/* Initialize fillerup() variables */
if (SDL_OpenAudio(&wave.spec, NULL) < 0) {
- fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
SDL_FreeWAV(wave.sound);
quit(2);
}
- printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+ SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
/* Let the audio run */
SDL_PauseAudio(0);
diff --git a/test/testatomic.c b/test/testatomic.c
index be60a61..b360616 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -45,39 +45,39 @@ void RunBasicTest()
SDL_atomic_t v;
SDL_bool tfret = SDL_FALSE;
- printf("\nspin lock---------------------------------------\n\n");
+ SDL_Log("\nspin lock---------------------------------------\n\n");
SDL_AtomicLock(&lock);
- printf("AtomicLock lock=%d\n", lock);
+ SDL_Log("AtomicLock lock=%d\n", lock);
SDL_AtomicUnlock(&lock);
- printf("AtomicUnlock lock=%d\n", lock);
+ SDL_Log("AtomicUnlock lock=%d\n", lock);
- printf("\natomic -----------------------------------------\n\n");
+ SDL_Log("\natomic -----------------------------------------\n\n");
SDL_AtomicSet(&v, 0);
- tfret = SDL_AtomicSet(&v, 10) == 0;
- printf("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
- tfret = SDL_AtomicAdd(&v, 10) == 10;
- printf("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
SDL_AtomicSet(&v, 0);
SDL_AtomicIncRef(&v);
- tfret = (SDL_AtomicGet(&v) == 1);
- printf("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
SDL_AtomicIncRef(&v);
- tfret = (SDL_AtomicGet(&v) == 2);
- printf("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
- tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
- printf("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
- tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
- printf("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
SDL_AtomicSet(&v, 10);
- tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE);
- printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
value = SDL_AtomicGet(&v);
- tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE);
- printf("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
+ tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
+ SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
}
/**************************************************************************/
@@ -120,7 +120,7 @@ static
int adder(void* junk)
{
unsigned long N=NInter;
- printf("Thread subtracting %d %lu times\n",CountInc,N);
+ SDL_Log("Thread subtracting %d %lu times\n",CountInc,N);
while (N--) {
SDL_AtomicAdd(&good, -CountInc);
bad-=CountInc;
@@ -152,7 +152,7 @@ void runAdder(void)
end = SDL_GetTicks();
- printf("Finished in %f sec\n", (end - start) / 1000.f);
+ SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
}
static
@@ -161,28 +161,28 @@ void RunEpicTest()
int b;
atomicValue v;
- printf("\nepic test---------------------------------------\n\n");
+ SDL_Log("\nepic test---------------------------------------\n\n");
- printf("Size asserted to be >= 32-bit\n");
+ SDL_Log("Size asserted to be >= 32-bit\n");
SDL_assert(sizeof(atomicValue)>=4);
- printf("Check static initializer\n");
+ SDL_Log("Check static initializer\n");
v=SDL_AtomicGet(&good);
SDL_assert(v==42);
SDL_assert(bad==42);
- printf("Test negative values\n");
+ SDL_Log("Test negative values\n");
SDL_AtomicSet(&good, -5);
v=SDL_AtomicGet(&good);
SDL_assert(v==-5);
- printf("Verify maximum value\n");
+ SDL_Log("Verify maximum value\n");
SDL_AtomicSet(&good, CountTo);
v=SDL_AtomicGet(&good);
SDL_assert(v==CountTo);
- printf("Test compare and exchange\n");
+ SDL_Log("Test compare and exchange\n");
b=SDL_AtomicCAS(&good, 500, 43);
SDL_assert(!b); /* no swap since CountTo!=500 */
@@ -194,7 +194,7 @@ void RunEpicTest()
v=SDL_AtomicGet(&good);
SDL_assert(v==44);
- printf("Test Add\n");
+ SDL_Log("Test Add\n");
v=SDL_AtomicAdd(&good, 1);
SDL_assert(v==44);
@@ -206,7 +206,7 @@ void RunEpicTest()
v=SDL_AtomicGet(&good);
SDL_assert(v==55);
- printf("Test Add (Negative values)\n");
+ SDL_Log("Test Add (Negative values)\n");
v=SDL_AtomicAdd(&good, -20);
SDL_assert(v==55);
@@ -223,7 +223,7 @@ void RunEpicTest()
v=SDL_AtomicGet(&good);
SDL_assert(v==15);
- printf("Reset before count down test\n");
+ SDL_Log("Reset before count down test\n");
SDL_AtomicSet(&good, CountTo);
v=SDL_AtomicGet(&good);
SDL_assert(v==CountTo);
@@ -231,11 +231,11 @@ void RunEpicTest()
bad=CountTo;
SDL_assert(bad==CountTo);
- printf("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
+ SDL_Log("Counting down from %d, Expect %d remaining\n",CountTo,Expect);
runAdder();
v=SDL_AtomicGet(&good);
- printf("Atomic %d Non-Atomic %d\n",v,bad);
+ SDL_Log("Atomic %d Non-Atomic %d\n",v,bad);
SDL_assert(v==Expect);
SDL_assert(bad!=Expect);
}
@@ -429,7 +429,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event
} else if (delta < 0) {
/* We ran into an old queue entry, which means it still needs to be dequeued */
} else {
- printf("ERROR: mutex failed!\n");
+ SDL_Log("ERROR: mutex failed!\n");
}
SDL_UnlockMutex(queue->mutex);
@@ -462,7 +462,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
} else if (delta < 0) {
/* We ran into an old queue entry, which means we've hit empty */
} else {
- printf("ERROR: mutex failed!\n");
+ SDL_Log("ERROR: mutex failed!\n");
}
SDL_UnlockMutex(queue->mutex);
@@ -598,9 +598,11 @@ static void RunFIFOTest(SDL_bool lock_free)
Uint32 start, end;
int i, j;
int grand_total;
+ char textBuffer[1024];
+ int len;
- printf("\nFIFO test---------------------------------------\n\n");
- printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
+ SDL_Log("\nFIFO test---------------------------------------\n\n");
+ SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
readersDone = SDL_CreateSemaphore(0);
writersDone = SDL_CreateSemaphore(0);
@@ -622,7 +624,7 @@ static void RunFIFOTest(SDL_bool lock_free)
#endif
/* Start the readers first */
- printf("Starting %d readers\n", NUM_READERS);
+ SDL_Log("Starting %d readers\n", NUM_READERS);
SDL_zero(readerData);
SDL_AtomicSet(&readersRunning, NUM_READERS);
for (i = 0; i < NUM_READERS; ++i) {
@@ -634,7 +636,7 @@ static void RunFIFOTest(SDL_bool lock_free)
}
/* Start up the writers */
- printf("Starting %d writers\n", NUM_WRITERS);
+ SDL_Log("Starting %d writers\n", NUM_WRITERS);
SDL_zero(writerData);
SDL_AtomicSet(&writersRunning, NUM_WRITERS);
for (i = 0; i < NUM_WRITERS; ++i) {
@@ -668,16 +670,16 @@ static void RunFIFOTest(SDL_bool lock_free)
SDL_DestroyMutex(queue.mutex);
}
- printf("Finished in %f sec\n", (end - start) / 1000.f);
+ SDL_Log("Finished in %f sec\n", (end - start) / 1000.f);
- printf("\n");
+ SDL_Log("\n");
for (i = 0; i < NUM_WRITERS; ++i) {
- printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
+ SDL_Log("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
}
- printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
+ SDL_Log("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
/* Print a breakdown of which readers read messages from which writer */
- printf("\n");
+ SDL_Log("\n");
grand_total = 0;
for (i = 0; i < NUM_READERS; ++i) {
int total = 0;
@@ -685,17 +687,21 @@ static void RunFIFOTest(SDL_bool lock_free)
total += readerData[i].counters[j];
}
grand_total += total;
- printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
- printf(" { ");
+ SDL_Log("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
+ SDL_snprintf(textBuffer, sizeof(textBuffer), " { ");
for (j = 0; j < NUM_WRITERS; ++j) {
if (j > 0) {
- printf(", ");
+ len = SDL_strlen(textBuffer);
+ SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", ");
}
- printf("%d", readerData[i].counters[j]);
+ len = SDL_strlen(textBuffer);
+ SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", readerData[i].counters[j]);
}
- printf(" }\n");
+ len = SDL_strlen(textBuffer);
+ SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n");
+ SDL_Log(textBuffer);
}
- printf("Readers read %d total events\n", grand_total);
+ SDL_Log("Readers read %d total events\n", grand_total);
}
/* End FIFO test */
@@ -704,6 +710,9 @@ static void RunFIFOTest(SDL_bool lock_free)
int
main(int argc, char *argv[])
{
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
RunBasicTest();
RunEpicTest();
/* This test is really slow, so don't run it by default */
diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c
index c1d7fa3..a65db5f 100644
--- a/test/testaudioinfo.c
+++ b/test/testaudioinfo.c
@@ -18,18 +18,18 @@ print_devices(int iscapture)
const char *typestr = ((iscapture) ? "capture" : "output");
int n = SDL_GetNumAudioDevices(iscapture);
- printf("%s devices:\n", typestr);
+ SDL_Log("%s devices:\n", typestr);
if (n == -1)
- printf(" Driver can't detect specific %s devices.\n\n", typestr);
+ SDL_Log(" Driver can't detect specific %s devices.\n\n", typestr);
else if (n == 0)
- printf(" No %s devices found.\n\n", typestr);
+ SDL_Log(" No %s devices found.\n\n", typestr);
else {
int i;
for (i = 0; i < n; i++) {
- printf(" %s\n", SDL_GetAudioDeviceName(i, iscapture));
+ SDL_Log(" %s\n", SDL_GetAudioDeviceName(i, iscapture));
}
- printf("\n");
+ SDL_Log("\n");
}
}
@@ -38,26 +38,29 @@ main(int argc, char **argv)
{
int n;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
/* Print available audio drivers */
n = SDL_GetNumAudioDrivers();
if (n == 0) {
- printf("No built-in audio drivers\n\n");
+ SDL_Log("No built-in audio drivers\n\n");
} else {
int i;
- printf("Built-in audio drivers:\n");
+ SDL_Log("Built-in audio drivers:\n");
for (i = 0; i < n; ++i) {
- printf(" %s\n", SDL_GetAudioDriver(i));
+ SDL_Log(" %s\n", SDL_GetAudioDriver(i));
}
- printf("\n");
+ SDL_Log("\n");
}
- printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
+ SDL_Log("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
print_devices(0);
print_devices(1);
diff --git a/test/testautomation.c b/test/testautomation.c
index 5eea7ec..6610d8a 100644
--- a/test/testautomation.c
+++ b/test/testautomation.c
@@ -80,8 +80,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr,
- "Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
+ SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n",
argv[0], SDLTest_CommonUsage(state));
quit(1);
}
diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c
index 3f6c56c..863a5bd 100644
--- a/test/testautomation_surface.c
+++ b/test/testautomation_surface.c
@@ -360,8 +360,6 @@ surface_testCompleteSurfaceConversion(void *arg)
for ( i = 0; i < SDL_arraysize(pixel_formats); ++i ) {
for ( j = 0; j < SDL_arraysize(pixel_formats); ++j ) {
- /*printf("Converting %s -> %s\n", SDL_GetPixelFormatName(pixel_formats[i]), SDL_GetPixelFormatName(pixel_formats[j]));*/
-
fmt1 = SDL_AllocFormat(pixel_formats[i]);
SDL_assert(fmt1 != NULL);
cvt1 = SDL_ConvertSurface(face, fmt1, 0);
diff --git a/test/testdraw2.c b/test/testdraw2.c
index a4509fe..926294b 100644
--- a/test/testdraw2.c
+++ b/test/testdraw2.c
@@ -176,6 +176,9 @@ main(int argc, char *argv[])
SDL_Event event;
Uint32 then, now, frames;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize parameters */
num_objects = NUM_OBJECTS;
@@ -218,8 +221,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr,
- "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+ SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
argv[0], SDLTest_CommonUsage(state));
return 1;
}
@@ -268,7 +270,7 @@ main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
- printf("%2.2f frames per second\n", fps);
+ SDL_Log("%2.2f frames per second\n", fps);
}
return 0;
}
diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c
index 002d8d7..567d3fb 100644
--- a/test/testdrawchessboard.c
+++ b/test/testdrawchessboard.c
@@ -54,10 +54,13 @@ main(int argc, char *argv[])
SDL_Surface *surface;
SDL_Renderer *renderer;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize SDL */
if(SDL_Init(SDL_INIT_VIDEO) != 0)
{
- fprintf(stderr,"SDL_Init fail : %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init fail : %s\n", SDL_GetError());
return 1;
}
@@ -66,14 +69,14 @@ main(int argc, char *argv[])
window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
if(!window)
{
- fprintf(stderr,"Window creation fail : %s\n",SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n",SDL_GetError());
return 1;
}
surface = SDL_GetWindowSurface(window);
renderer = SDL_CreateSoftwareRenderer(surface);
if(!renderer)
{
- fprintf(stderr,"Render creation for surface fail : %s\n",SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n",SDL_GetError());
return 1;
}
diff --git a/test/testerror.c b/test/testerror.c
index e7356c0..e9c76ff 100644
--- a/test/testerror.c
+++ b/test/testerror.c
@@ -36,10 +36,10 @@ ThreadFunc(void *data)
SDL_SetError("Thread %s (%lu) had a problem: %s",
(char *) data, SDL_ThreadID(), "nevermind");
while (alive) {
- printf("Thread '%s' is alive!\n", (char *) data);
+ SDL_Log("Thread '%s' is alive!\n", (char *) data);
SDL_Delay(1 * 1000);
}
- printf("Child thread error string: %s\n", SDL_GetError());
+ SDL_Log("Child thread error string: %s\n", SDL_GetError());
return (0);
}
@@ -48,9 +48,12 @@ main(int argc, char *argv[])
{
SDL_Thread *thread;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(0) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
@@ -60,15 +63,15 @@ main(int argc, char *argv[])
alive = 1;
thread = SDL_CreateThread(ThreadFunc, NULL, "#1");
if (thread == NULL) {
- fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}
SDL_Delay(5 * 1000);
- printf("Waiting for thread #1\n");
+ SDL_Log("Waiting for thread #1\n");
alive = 0;
SDL_WaitThread(thread, NULL);
- printf("Main thread error string: %s\n", SDL_GetError());
+ SDL_Log("Main thread error string: %s\n", SDL_GetError());
SDL_Quit();
return (0);
diff --git a/test/testfile.c b/test/testfile.c
index d82d0eb..efdc415 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -44,7 +44,6 @@
static void
cleanup(void)
{
-
unlink(FBASENAME1);
unlink(FBASENAME2);
}
@@ -52,8 +51,7 @@ cleanup(void)
static void
rwops_error_quit(unsigned line, SDL_RWops * rwops)
{
-
- printf("testfile.c(%d): failed\n", line);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "testfile.c(%d): failed\n", line);
if (rwops) {
rwops->close(rwops); /* This calls SDL_FreeRW(rwops); */
}
@@ -71,6 +69,9 @@ main(int argc, char *argv[])
SDL_RWops *rwops = NULL;
char test_buf[30];
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
cleanup();
/* test 1 : basic argument test: all those calls to SDL_RWFromFile should fail */
@@ -90,7 +91,7 @@ main(int argc, char *argv[])
rwops = SDL_RWFromFile("something", NULL);
if (rwops)
RWOP_ERR_QUIT(rwops);
- printf("test1 OK\n");
+ SDL_Log("test1 OK\n");
/* test 2 : check that inexistent file is not successfully opened/created when required */
/* modes : r, r+ imply that file MUST exist
@@ -123,7 +124,7 @@ main(int argc, char *argv[])
RWOP_ERR_QUIT(rwops);
rwops->close(rwops);
unlink(FBASENAME2);
- printf("test2 OK\n");
+ SDL_Log("test2 OK\n");
/* test 3 : creation, writing , reading, seeking,
test : w mode, r mode, w+ mode
@@ -201,7 +202,7 @@ main(int argc, char *argv[])
if (SDL_memcmp(test_buf, "12345678901234567890", 20))
RWOP_ERR_QUIT(rwops);
rwops->close(rwops);
- printf("test3 OK\n");
+ SDL_Log("test3 OK\n");
/* test 4: same in r+ mode */
rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */
@@ -236,7 +237,7 @@ main(int argc, char *argv[])
if (SDL_memcmp(test_buf, "12345678901234567890", 20))
RWOP_ERR_QUIT(rwops);
rwops->close(rwops);
- printf("test4 OK\n");
+ SDL_Log("test4 OK\n");
/* test5 : append mode */
rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */
@@ -277,7 +278,7 @@ main(int argc, char *argv[])
if (SDL_memcmp(test_buf, "123456789012345678901234567123", 30))
RWOP_ERR_QUIT(rwops);
rwops->close(rwops);
- printf("test5 OK\n");
+ SDL_Log("test5 OK\n");
cleanup();
return 0; /* all ok */
}
diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c
index cd18aa5..419593d 100644
--- a/test/testgamecontroller.c
+++ b/test/testgamecontroller.c
@@ -91,7 +91,7 @@ WatchGameController(SDL_GameController * gamecontroller)
const char *name = SDL_GameControllerName(gamecontroller);
const char *basetitle = "Game Controller Test: ";
const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1;
- char *title = SDL_malloc(titlelen);
+ char *title = (char *)SDL_malloc(titlelen);
SDL_Window *window = NULL;
SDL_Renderer *screen = NULL;
int done = 0;
@@ -107,13 +107,13 @@ WatchGameController(SDL_GameController * gamecontroller)
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) {
- fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return;
}
screen = SDL_CreateRenderer(window, -1, 0);
if (screen == NULL) {
- fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
return;
}
@@ -124,7 +124,7 @@ WatchGameController(SDL_GameController * gamecontroller)
SDL_RaiseWindow(window);
/* Print info about the controller we are watching */
- printf("Watching controller %s\n", name ? name : "Unknown Controller");
+ SDL_Log("Watching controller %s\n", name ? name : "Unknown Controller");
/* Loop, getting controller events! */
while (!done) {
@@ -135,21 +135,21 @@ WatchGameController(SDL_GameController * gamecontroller)
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_CONTROLLERAXISMOTION:
- printf("Controller %d axis %d ('%s') value: %d\n",
+ SDL_Log("Controller %d axis %d ('%s') value: %d\n",
event.caxis.which,
event.caxis.axis,
- ControllerAxisName(event.caxis.axis),
+ ControllerAxisName((SDL_GameControllerAxis)event.caxis.axis),
event.caxis.value);
break;
case SDL_CONTROLLERBUTTONDOWN:
- printf("Controller %d button %d ('%s') down\n",
+ SDL_Log("Controller %d button %d ('%s') down\n",
event.cbutton.which, event.cbutton.button,
- ControllerButtonName(event.cbutton.button));
+ ControllerButtonName((SDL_GameControllerButton)event.cbutton.button));
break;
case SDL_CONTROLLERBUTTONUP:
- printf("Controller %d button %d ('%s') up\n",
+ SDL_Log("Controller %d button %d ('%s') up\n",
event.cbutton.which, event.cbutton.button,
- ControllerButtonName(event.cbutton.button));
+ ControllerButtonName((SDL_GameControllerButton)event.cbutton.button));
break;
case SDL_KEYDOWN:
if (event.key.keysym.sym != SDLK_ESCAPE) {
@@ -167,7 +167,7 @@ WatchGameController(SDL_GameController * gamecontroller)
/* Update visual controller state */
SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE);
for (i = 0; i <SDL_CONTROLLER_BUTTON_MAX; ++i) {
- if (SDL_GameControllerGetButton(gamecontroller, i) == SDL_PRESSED) {
+ if (SDL_GameControllerGetButton(gamecontroller, (SDL_GameControllerButton)i) == SDL_PRESSED) {
DrawRect(screen, i * 34, SCREEN_HEIGHT - 34, 32, 32);
}
}
@@ -176,7 +176,7 @@ WatchGameController(SDL_GameController * gamecontroller)
for (i = 0; i < SDL_CONTROLLER_AXIS_MAX / 2; ++i) {
/* Draw the X/Y axis */
int x, y;
- x = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 0)) + 32768);
+ x = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 0))) + 32768);
x *= SCREEN_WIDTH;
x /= 65535;
if (x < 0) {
@@ -184,7 +184,7 @@ WatchGameController(SDL_GameController * gamecontroller)
} else if (x > (SCREEN_WIDTH - 16)) {
x = SCREEN_WIDTH - 16;
}
- y = (((int) SDL_GameControllerGetAxis(gamecontroller, i * 2 + 1)) + 32768);
+ y = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 1))) + 32768);
y *= SCREEN_HEIGHT;
y /= 65535;
if (y < 0) {
@@ -217,9 +217,12 @@ main(int argc, char *argv[])
char guid[64];
SDL_GameController *gamecontroller;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER ) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
@@ -238,22 +241,22 @@ main(int argc, char *argv[])
} else {
name = SDL_JoystickNameForIndex(i);
}
- printf("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
+ SDL_Log("%s %d: %s (guid %s)\n", description, i, name ? name : "Unknown", guid);
}
- printf("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
+ SDL_Log("There are %d game controller(s) attached (%d joystick(s))\n", nController, SDL_NumJoysticks());
if (argv[1]) {
int device = atoi(argv[1]);
if (device >= SDL_NumJoysticks()) {
- printf("%i is an invalid joystick index.\n", device);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%i is an invalid joystick index.\n", device);
retcode = 1;
} else {
SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(device),
guid, sizeof (guid));
- printf("Attempting to open device %i, guid %s\n", device, guid);
+ SDL_Log("Attempting to open device %i, guid %s\n", device, guid);
gamecontroller = SDL_GameControllerOpen(device);
if (gamecontroller == NULL) {
- printf("Couldn't open joystick %d: %s\n", device, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open joystick %d: %s\n", device, SDL_GetError());
retcode = 1;
} else {
WatchGameController(gamecontroller);
@@ -272,7 +275,7 @@ main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
- fprintf(stderr, "SDL compiled without Joystick support.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
exit(1);
}
diff --git a/test/testgesture.c b/test/testgesture.c
index e2a9694..7d4fe78 100644
--- a/test/testgesture.c
+++ b/test/testgesture.c
@@ -207,6 +207,9 @@ int main(int argc, char* argv[])
SDL_bool quitting = SDL_FALSE;
SDL_RWops *src;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
//gesture variables
knob.r = .1f;
knob.ang = 0;
diff --git a/test/testgl2.c b/test/testgl2.c
index eb1a245..571a69d 100644
--- a/test/testgl2.c
+++ b/test/testgl2.c
@@ -181,6 +181,9 @@ main(int argc, char *argv[])
Uint32 then, now, frames;
int status;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize parameters */
fsaa = 0;
accel = -1;
@@ -206,7 +209,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr, "Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
+ SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0],
SDLTest_CommonUsage(state));
quit(1);
}
@@ -235,7 +238,7 @@ main(int argc, char *argv[])
/* Create OpenGL context */
context = SDL_GL_CreateContext(state->windows[0]);
if (!context) {
- fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
quit(2);
}
@@ -249,63 +252,63 @@ main(int argc, char *argv[])
}
SDL_GetCurrentDisplayMode(0, &mode);
- printf("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format));
- printf("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
- printf("\n");
- printf("Vendor : %s\n", glGetString(GL_VENDOR));
- printf("Renderer : %s\n", glGetString(GL_RENDERER));
- printf("Version : %s\n", glGetString(GL_VERSION));
- printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
- printf("\n");
+ SDL_Log("Screen BPP : %d\n", SDL_BITSPERPIXEL(mode.format));
+ SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval());
+ SDL_Log("\n");
+ SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR));
+ SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER));
+ SDL_Log("Version : %s\n", glGetString(GL_VERSION));
+ SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
+ SDL_Log("\n");
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
- printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+ SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
- printf("Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
- printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+ SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
- printf("Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
- printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+ SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
- printf("Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
- printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
+ SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
} else {
- printf("Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
}
if (fsaa) {
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
- printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+ SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
- printf("Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
- printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+ SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
- printf("Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_GetError());
}
}
if (accel >= 0) {
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
- printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
+ SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
value);
} else {
- printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_GetError());
}
}
@@ -343,7 +346,7 @@ main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
- printf("%2.2f frames per second\n",
+ SDL_Log("%2.2f frames per second\n",
((double) frames * 1000) / (now - then));
}
quit(0);
@@ -355,7 +358,7 @@ main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
- printf("No OpenGL support on this system\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
return 1;
}
diff --git a/test/testgles.c b/test/testgles.c
index 41312a8..7a790bd 100644
--- a/test/testgles.c
+++ b/test/testgles.c
@@ -110,6 +110,9 @@ main(int argc, char *argv[])
Uint32 then, now, frames;
int status;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize parameters */
fsaa = 0;
accel = 0;
@@ -143,7 +146,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
+ SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
SDLTest_CommonUsage(state));
quit(1);
}
@@ -169,7 +172,7 @@ main(int argc, char *argv[])
context = SDL_calloc(state->num_windows, sizeof(context));
if (context == NULL) {
- fprintf(stderr, "Out of memory!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
@@ -177,7 +180,7 @@ main(int argc, char *argv[])
for (i = 0; i < state->num_windows; i++) {
context[i] = SDL_GL_CreateContext(state->windows[i]);
if (!context[i]) {
- fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
quit(2);
}
}
@@ -189,65 +192,65 @@ main(int argc, char *argv[])
}
SDL_GetCurrentDisplayMode(0, &mode);
- printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
- printf("\n");
- printf("Vendor : %s\n", glGetString(GL_VENDOR));
- printf("Renderer : %s\n", glGetString(GL_RENDERER));
- printf("Version : %s\n", glGetString(GL_VERSION));
- printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
- printf("\n");
+ SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
+ SDL_Log("\n");
+ SDL_Log("Vendor : %s\n", glGetString(GL_VENDOR));
+ SDL_Log("Renderer : %s\n", glGetString(GL_RENDERER));
+ SDL_Log("Version : %s\n", glGetString(GL_VERSION));
+ SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
+ SDL_Log("\n");
status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
if (!status) {
- printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+ SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
if (!status) {
- printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+ SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
if (!status) {
- printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+ SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
if (!status) {
- printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
+ SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
SDL_GetError());
}
if (fsaa) {
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
if (!status) {
- printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+ SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
SDL_GetError());
}
status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
if (!status) {
- printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+ SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
SDL_GetError());
}
}
if (accel) {
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
if (!status) {
- printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
+ SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
} else {
- fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_GetError());
}
}
@@ -258,7 +261,7 @@ main(int argc, char *argv[])
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
- printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+ SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */
continue;
@@ -292,7 +295,7 @@ main(int argc, char *argv[])
if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
- printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+ SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
break;
}
/* Change view port to the new window dimensions */
@@ -311,7 +314,7 @@ main(int argc, char *argv[])
for (i = 0; i < state->num_windows; ++i) {
status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
if (status) {
- printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+ SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
/* Continue for next window */
continue;
@@ -324,7 +327,7 @@ main(int argc, char *argv[])
/* Print out some timing information */
now = SDL_GetTicks();
if (now > then) {
- printf("%2.2f frames per second\n",
+ SDL_Log("%2.2f frames per second\n",
((double) frames * 1000) / (now - then));
}
quit(0);
@@ -336,7 +339,7 @@ main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
- printf("No OpenGL ES support on this system\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
return 1;
}
diff --git a/test/testhaptic.c b/test/testhaptic.c
index 13dd19d..c28d0df 100644
--- a/test/testhaptic.c
+++ b/test/testhaptic.c
@@ -26,7 +26,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* includes
*/
#include <stdlib.h>
-#include <stdio.h> /* printf */
#include <string.h> /* strstr */
#include <ctype.h> /* isdigit */
@@ -62,12 +61,15 @@ main(int argc, char **argv)
int nefx;
unsigned int supported;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
name = NULL;
index = -1;
if (argc > 1) {
name = argv[1];
if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
- printf("USAGE: %s [device]\n"
+ SDL_Log("USAGE: %s [device]\n"
"If device is a two-digit number it'll use it as an index, otherwise\n"
"it'll use it as if it were part of the device's name.\n",
argv[0]);
@@ -84,7 +86,7 @@ main(int argc, char **argv)
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
SDL_INIT_HAPTIC);
- printf("%d Haptic devices detected.\n", SDL_NumHaptics());
+ SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
if (SDL_NumHaptics() > 0) {
/* We'll just use index or the first force feedback device found */
if (name == NULL) {
@@ -98,7 +100,7 @@ main(int argc, char **argv)
}
if (i >= SDL_NumHaptics()) {
- printf("Unable to find device matching '%s', aborting.\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
name);
return 1;
}
@@ -106,14 +108,14 @@ main(int argc, char **argv)
haptic = SDL_HapticOpen(i);
if (haptic == NULL) {
- printf("Unable to create the haptic device: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
SDL_GetError());
return 1;
}
- printf("Device: %s\n", SDL_HapticName(i));
+ SDL_Log("Device: %s\n", SDL_HapticName(i));
HapticPrintSupported(haptic);
} else {
- printf("No Haptic devices found!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
return 1;
}
@@ -125,10 +127,10 @@ main(int argc, char **argv)
nefx = 0;
supported = SDL_HapticQuery(haptic);
- printf("\nUploading effects\n");
+ SDL_Log("\nUploading effects\n");
/* First we'll try a SINE effect. */
if (supported & SDL_HAPTIC_SINE) {
- printf(" effect %d: Sine Wave\n", nefx);
+ SDL_Log(" effect %d: Sine Wave\n", nefx);
efx[nefx].type = SDL_HAPTIC_SINE;
efx[nefx].periodic.period = 1000;
efx[nefx].periodic.magnitude = 0x4000;
@@ -137,14 +139,14 @@ main(int argc, char **argv)
efx[nefx].periodic.fade_length = 1000;
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
- printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
}
/* Now we'll try a SAWTOOTHUP */
if (supported & SDL_HAPTIC_SAWTOOTHUP) {
- printf(" effect %d: Sawtooth Up\n", nefx);
+ SDL_Log(" effect %d: Sawtooth Up\n", nefx);
efx[nefx].type = SDL_HAPTIC_SAWTOOTHUP;
efx[nefx].periodic.period = 500;
efx[nefx].periodic.magnitude = 0x5000;
@@ -153,14 +155,14 @@ main(int argc, char **argv)
efx[nefx].periodic.fade_length = 1000;
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
- printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
}
/* Now the classical constant effect. */
if (supported & SDL_HAPTIC_CONSTANT) {
- printf(" effect %d: Constant Force\n", nefx);
+ SDL_Log(" effect %d: Constant Force\n", nefx);
efx[nefx].type = SDL_HAPTIC_CONSTANT;
efx[nefx].constant.direction.type = SDL_HAPTIC_POLAR;
efx[nefx].constant.direction.dir[0] = 20000; /* Force comes from the south-west. */
@@ -170,14 +172,14 @@ main(int argc, char **argv)
efx[nefx].constant.fade_length = 1000;
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
- printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
}
/* The cute spring effect. */
if (supported & SDL_HAPTIC_SPRING) {
- printf(" effect %d: Condition Spring\n", nefx);
+ SDL_Log(" effect %d: Condition Spring\n", nefx);
efx[nefx].type = SDL_HAPTIC_SPRING;
efx[nefx].condition.length = 5000;
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
@@ -189,14 +191,14 @@ main(int argc, char **argv)
}
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
- printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
}
/* The pretty awesome inertia effect. */
if (supported & SDL_HAPTIC_INERTIA) {
- printf(" effect %d: Condition Inertia\n", nefx);
+ SDL_Log(" effect %d: Condition Inertia\n", nefx);
efx[nefx].type = SDL_HAPTIC_SPRING;
efx[nefx].condition.length = 5000;
for (i = 0; i < SDL_HapticNumAxes(haptic); i++) {
@@ -207,7 +209,7 @@ main(int argc, char **argv)
}
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
- printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
@@ -215,24 +217,24 @@ main(int argc, char **argv)
/* Finally we'll try a left/right effect. */
if (supported & SDL_HAPTIC_LEFTRIGHT) {
- printf(" effect %d: Left/Right\n", nefx);
+ SDL_Log(" effect %d: Left/Right\n", nefx);
efx[nefx].type = SDL_HAPTIC_LEFTRIGHT;
efx[nefx].leftright.length = 5000;
efx[nefx].leftright.large_magnitude = 0x3000;
efx[nefx].leftright.small_magnitude = 0xFFFF;
id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]);
if (id[nefx] < 0) {
- printf("UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError());
abort_execution();
}
nefx++;
}
- printf
+ SDL_Log
("\nNow playing effects for 5 seconds each with 1 second delay between\n");
for (i = 0; i < nefx; i++) {
- printf(" Playing effect %d\n", i);
+ SDL_Log(" Playing effect %d\n", i);
SDL_HapticRunEffect(haptic, id[i], 1);
SDL_Delay(6000); /* Effects only have length 5000 */
}
@@ -252,7 +254,7 @@ main(int argc, char **argv)
static void
abort_execution(void)
{
- printf("\nAborting program execution.\n");
+ SDL_Log("\nAborting program execution.\n");
SDL_HapticClose(haptic);
SDL_Quit();
@@ -270,42 +272,42 @@ HapticPrintSupported(SDL_Haptic * haptic)
unsigned int supported;
supported = SDL_HapticQuery(haptic);
- printf(" Supported effects [%d effects, %d playing]:\n",
+ SDL_Log(" Supported effects [%d effects, %d playing]:\n",
SDL_HapticNumEffects(haptic), SDL_HapticNumEffectsPlaying(haptic));
if (supported & SDL_HAPTIC_CONSTANT)
- printf(" constant\n");
+ SDL_Log(" constant\n");
if (supported & SDL_HAPTIC_SINE)
- printf(" sine\n");
+ SDL_Log(" sine\n");
/* !!! FIXME: put this back when we have more bits in 2.1 */
/*if (supported & SDL_HAPTIC_SQUARE)
- printf(" square\n");*/
+ SDL_Log(" square\n");*/
if (supported & SDL_HAPTIC_TRIANGLE)
- printf(" triangle\n");
+ SDL_Log(" triangle\n");
if (supported & SDL_HAPTIC_SAWTOOTHUP)
- printf(" sawtoothup\n");
+ SDL_Log(" sawtoothup\n");
if (supported & SDL_HAPTIC_SAWTOOTHDOWN)
- printf(" sawtoothdown\n");
+ SDL_Log(" sawtoothdown\n");
if (supported & SDL_HAPTIC_RAMP)
- printf(" ramp\n");
+ SDL_Log(" ramp\n");
if (supported & SDL_HAPTIC_FRICTION)
- printf(" friction\n");
+ SDL_Log(" friction\n");
if (supported & SDL_HAPTIC_SPRING)
- printf(" spring\n");
+ SDL_Log(" spring\n");
if (supported & SDL_HAPTIC_DAMPER)
- printf(" damper\n");
+ SDL_Log(" damper\n");
if (supported & SDL_HAPTIC_INERTIA)
- printf(" intertia\n");
+ SDL_Log(" inertia\n");
if (supported & SDL_HAPTIC_CUSTOM)
- printf(" custom\n");
+ SDL_Log(" custom\n");
if (supported & SDL_HAPTIC_LEFTRIGHT)
- printf(" left/right\n");
- printf(" Supported capabilities:\n");
+ SDL_Log(" left/right\n");
+ SDL_Log(" Supported capabilities:\n");
if (supported & SDL_HAPTIC_GAIN)
- printf(" gain\n");
+ SDL_Log(" gain\n");
if (supported & SDL_HAPTIC_AUTOCENTER)
- printf(" autocenter\n");
+ SDL_Log(" autocenter\n");
if (supported & SDL_HAPTIC_STATUS)
- printf(" status\n");
+ SDL_Log(" status\n");
}
#else
@@ -313,7 +315,7 @@ HapticPrintSupported(SDL_Haptic * haptic)
int
main(int argc, char *argv[])
{
- fprintf(stderr, "SDL compiled without Haptic support.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
exit(1);
}
diff --git a/test/testiconv.c b/test/testiconv.c
index d208199..435e239 100644
--- a/test/testiconv.c
+++ b/test/testiconv.c
@@ -49,12 +49,15 @@ main(int argc, char *argv[])
FILE *file;
int errors = 0;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (!argv[1]) {
argv[1] = "utf8.txt";
}
file = fopen(argv[1], "rb");
if (!file) {
- fprintf(stderr, "Unable to open %s\n", argv[1]);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", argv[1]);
return (1);
}
@@ -69,7 +72,7 @@ main(int argc, char *argv[])
test[0] = SDL_iconv_string(formats[i], "UCS-4", ucs4, len);
test[1] = SDL_iconv_string("UCS-4", formats[i], test[0], len);
if (!test[1] || SDL_memcmp(test[1], ucs4, len) != 0) {
- fprintf(stderr, "FAIL: %s\n", formats[i]);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
++errors;
}
if (test[0]) {
diff --git a/test/testime.c b/test/testime.c
index ce9f02b..44f1b19 100644
--- a/test/testime.c
+++ b/test/testime.c
@@ -80,7 +80,7 @@ char *utf8_advance(char *p, size_t distance)
void usage()
{
- printf("usage: testime [--font fontfile]\n");
+ SDL_Log("usage: testime [--font fontfile]\n");
exit(0);
}
@@ -210,6 +210,9 @@ int main(int argc, char *argv[]) {
SDL_Event event;
const char *fontname = DEFAULT_FONT;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
@@ -251,12 +254,12 @@ int main(int argc, char *argv[]) {
font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
if (! font)
{
- fprintf(stderr, "Failed to find font: %s\n", TTF_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
exit(-1);
}
#endif
- printf("Using font: %s\n", fontname);
+ SDL_Log("Using font: %s\n", fontname);
atexit(SDL_Quit);
InitInput();
@@ -321,8 +324,7 @@ int main(int argc, char *argv[]) {
break;
}
- fprintf(stderr,
- "Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
+ SDL_Log("Keyboard: scancode 0x%08X = %s, keycode 0x%08X = %s\n",
event.key.keysym.scancode,
SDL_GetScancodeName(event.key.keysym.scancode),
event.key.keysym.sym, SDL_GetKeyName(event.key.keysym.sym));
@@ -333,12 +335,12 @@ int main(int argc, char *argv[]) {
markedRect.w < 0)
break;
- fprintf(stderr, "Keyboard: text input \"%s\"\n", event.text.text);
+ SDL_Log("Keyboard: text input \"%s\"\n", event.text.text);
if (SDL_strlen(text) + SDL_strlen(event.text.text) < sizeof(text))
SDL_strlcat(text, event.text.text, sizeof(text));
- fprintf(stderr, "text inputed: %s\n", text);
+ SDL_Log("text inputed: %s\n", text);
// After text inputed, we can clear up markedText because it
// is committed
@@ -347,7 +349,7 @@ int main(int argc, char *argv[]) {
break;
case SDL_TEXTEDITING:
- fprintf(stderr, "text editing \"%s\", selected range (%d, %d)\n",
+ SDL_Log("text editing \"%s\", selected range (%d, %d)\n",
event.edit.text, event.edit.start, event.edit.length);
strcpy(markedText, event.edit.text);
diff --git a/test/testintersections.c b/test/testintersections.c
index d858717..237bd35 100644
--- a/test/testintersections.c
+++ b/test/testintersections.c
@@ -84,7 +84,7 @@ add_line(int x1, int y1, int x2, int y2)
if ((x1 == x2) && (y1 == y2))
return 0;
- printf("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
+ SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
lines[num_lines].x = x1;
lines[num_lines].y = y1;
lines[num_lines].w = x2;
@@ -133,7 +133,7 @@ add_rect(int x1, int y1, int x2, int y2)
if (y1 > y2)
SWAP(int, y1, y2);
- printf("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
+ SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
x2 - x1, y2 - y1);
rects[num_rects].x = x1;
@@ -199,6 +199,9 @@ main(int argc, char *argv[])
SDL_Event event;
Uint32 then, now, frames;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize parameters */
num_objects = NUM_OBJECTS;
@@ -241,8 +244,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr,
- "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
+ SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
argv[0], SDLTest_CommonUsage(state));
return 1;
}
@@ -327,7 +329,7 @@ main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
- printf("%2.2f frames per second\n", fps);
+ SDL_Log("%2.2f frames per second\n", fps);
}
return 0;
}
diff --git a/test/testjoystick.c b/test/testjoystick.c
index da307ed..7d3c573 100644
--- a/test/testjoystick.c
+++ b/test/testjoystick.c
@@ -52,13 +52,13 @@ WatchJoystick(SDL_Joystick * joystick)
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) {
- fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE;
}
screen = SDL_CreateRenderer(window, -1, 0);
if (screen == NULL) {
- fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
return SDL_FALSE;
}
@@ -70,9 +70,9 @@ WatchJoystick(SDL_Joystick * joystick)
/* Print info about the joystick we are watching */
name = SDL_JoystickName(joystick);
- printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
+ SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
name ? name : "Unknown Joystick");
- printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
+ SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
@@ -85,36 +85,36 @@ WatchJoystick(SDL_Joystick * joystick)
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_JOYAXISMOTION:
- printf("Joystick %d axis %d value: %d\n",
+ SDL_Log("Joystick %d axis %d value: %d\n",
event.jaxis.which,
event.jaxis.axis, event.jaxis.value);
break;
case SDL_JOYHATMOTION:
- printf("Joystick %d hat %d value:",
+ SDL_Log("Joystick %d hat %d value:",
event.jhat.which, event.jhat.hat);
if (event.jhat.value == SDL_HAT_CENTERED)
- printf(" centered");
+ SDL_Log(" centered");
if (event.jhat.value & SDL_HAT_UP)
- printf(" up");
+ SDL_Log(" up");
if (event.jhat.value & SDL_HAT_RIGHT)
- printf(" right");
+ SDL_Log(" right");
if (event.jhat.value & SDL_HAT_DOWN)
- printf(" down");
+ SDL_Log(" down");
if (event.jhat.value & SDL_HAT_LEFT)
- printf(" left");
- printf("\n");
+ SDL_Log(" left");
+ SDL_Log("\n");
break;
case SDL_JOYBALLMOTION:
- printf("Joystick %d ball %d delta: (%d,%d)\n",
+ SDL_Log("Joystick %d ball %d delta: (%d,%d)\n",
event.jball.which,
event.jball.ball, event.jball.xrel, event.jball.yrel);
break;
case SDL_JOYBUTTONDOWN:
- printf("Joystick %d button %d down\n",
+ SDL_Log("Joystick %d button %d down\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_JOYBUTTONUP:
- printf("Joystick %d button %d up\n",
+ SDL_Log("Joystick %d button %d up\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_KEYDOWN:
@@ -211,31 +211,34 @@ main(int argc, char *argv[])
int i;
SDL_Joystick *joystick;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
/* Print information about the joysticks */
- printf("There are %d joysticks attached\n", SDL_NumJoysticks());
+ SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks());
for (i = 0; i < SDL_NumJoysticks(); ++i) {
name = SDL_JoystickNameForIndex(i);
- printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
+ SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
joystick = SDL_JoystickOpen(i);
if (joystick == NULL) {
- fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i,
SDL_GetError());
} else {
char guid[64];
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
guid, sizeof (guid));
- printf(" axes: %d\n", SDL_JoystickNumAxes(joystick));
- printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
- printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
- printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
- printf("instance id: %d\n", SDL_JoystickInstanceID(joystick));
- printf(" guid: %s\n", guid);
+ SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick));
+ SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick));
+ SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick));
+ SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
+ SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick));
+ SDL_Log(" guid: %s\n", guid);
SDL_JoystickClose(joystick);
}
}
@@ -256,7 +259,7 @@ main(int argc, char *argv[])
while ( keepGoing ) {
if (joystick == NULL) {
if ( !reportederror ) {
- printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
+ SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
keepGoing = SDL_FALSE;
reportederror = SDL_TRUE;
}
@@ -268,7 +271,7 @@ main(int argc, char *argv[])
joystick = NULL;
if (keepGoing) {
- printf("Waiting for attach\n");
+ SDL_Log("Waiting for attach\n");
}
while (keepGoing) {
SDL_WaitEvent(&event);
@@ -296,7 +299,7 @@ main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
- fprintf(stderr, "SDL compiled without Joystick support.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
exit(1);
}
diff --git a/test/testkeys.c b/test/testkeys.c
index 71f8956..f4a35ab 100644
--- a/test/testkeys.c
+++ b/test/testkeys.c
@@ -24,12 +24,15 @@ main(int argc, char *argv[])
{
SDL_Scancode scancode;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
- printf("Scancode #%d, \"%s\"\n", scancode,
+ SDL_Log("Scancode #%d, \"%s\"\n", scancode,
SDL_GetScancodeName(scancode));
}
SDL_Quit();
diff --git a/test/testloadso.c b/test/testloadso.c
index 4bf7bf6..946aafd 100644
--- a/test/testloadso.c
+++ b/test/testloadso.c
@@ -33,14 +33,14 @@ main(int argc, char *argv[])
if (argc != 3) {
const char *app = argv[0];
- fprintf(stderr, "USAGE: %s <library> <functionname>\n", app);
- fprintf(stderr, " %s --hello <lib with puts()>\n", app);
+ SDL_Log("USAGE: %s <library> <functionname>\n", app);
+ SDL_Log(" %s --hello <lib with puts()>\n", app);
return 1;
}
/* Initialize SDL */
if (SDL_Init(0) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 2;
}
@@ -55,23 +55,23 @@ main(int argc, char *argv[])
lib = SDL_LoadObject(libname);
if (lib == NULL) {
- fprintf(stderr, "SDL_LoadObject('%s') failed: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n",
libname, SDL_GetError());
retval = 3;
} else {
fn = (fntype) SDL_LoadFunction(lib, symname);
if (fn == NULL) {
- fprintf(stderr, "SDL_LoadFunction('%s') failed: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n",
symname, SDL_GetError());
retval = 4;
} else {
- printf("Found %s in %s at %p\n", symname, libname, fn);
+ SDL_Log("Found %s in %s at %p\n", symname, libname, fn);
if (hello) {
- printf("Calling function...\n");
+ SDL_Log("Calling function...\n");
fflush(stdout);
fn(" HELLO, WORLD!\n");
- printf("...apparently, we survived. :)\n");
- printf("Unloading library...\n");
+ SDL_Log("...apparently, we survived. :)\n");
+ SDL_Log("Unloading library...\n");
fflush(stdout);
}
}
diff --git a/test/testlock.c b/test/testlock.c
index fcfeb8b..0414fe3 100644
--- a/test/testlock.c
+++ b/test/testlock.c
@@ -40,7 +40,7 @@ SDL_Quit_Wrapper(void)
void
printid(void)
{
- printf("Process %lu: exiting\n", SDL_ThreadID());
+ SDL_Log("Process %lu: exiting\n", SDL_ThreadID());
}
void
@@ -55,7 +55,7 @@ closemutex(int sig)
{
SDL_threadID id = SDL_ThreadID();
int i;
- printf("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id);
+ SDL_Log("Process %lu: Cleaning up...\n", id == mainthread ? 0 : id);
doterminate = 1;
for (i = 0; i < 6; ++i)
SDL_WaitThread(threads[i], NULL);
@@ -69,23 +69,23 @@ Run(void *data)
if (SDL_ThreadID() == mainthread)
signal(SIGTERM, closemutex);
while (!doterminate) {
- printf("Process %lu ready to work\n", SDL_ThreadID());
+ SDL_Log("Process %lu ready to work\n", SDL_ThreadID());
if (SDL_LockMutex(mutex) < 0) {
- fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock mutex: %s", SDL_GetError());
exit(1);
}
- printf("Process %lu, working!\n", SDL_ThreadID());
+ SDL_Log("Process %lu, working!\n", SDL_ThreadID());
SDL_Delay(1 * 1000);
- printf("Process %lu, done!\n", SDL_ThreadID());
+ SDL_Log("Process %lu, done!\n", SDL_ThreadID());
if (SDL_UnlockMutex(mutex) < 0) {
- fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't unlock mutex: %s", SDL_GetError());
exit(1);
}
/* If this sleep isn't done, then threads may starve */
SDL_Delay(10);
}
if (SDL_ThreadID() == mainthread && doterminate) {
- printf("Process %lu: raising SIGTERM\n", SDL_ThreadID());
+ SDL_Log("Process %lu: raising SIGTERM\n", SDL_ThreadID());
raise(SIGTERM);
}
return (0);
@@ -97,26 +97,29 @@ main(int argc, char *argv[])
int i;
int maxproc = 6;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(0) < 0) {
- fprintf(stderr, "%s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit_Wrapper);
if ((mutex = SDL_CreateMutex()) == NULL) {
- fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError());
exit(1);
}
mainthread = SDL_ThreadID();
- printf("Main thread: %lu\n", mainthread);
+ SDL_Log("Main thread: %lu\n", mainthread);
atexit(printid);
for (i = 0; i < maxproc; ++i) {
char name[64];
SDL_snprintf(name, sizeof (name), "Worker%d", i);
if ((threads[i] = SDL_CreateThread(Run, name, NULL)) == NULL)
- fprintf(stderr, "Couldn't create thread!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!\n");
}
signal(SIGINT, terminate);
Run(NULL);
diff --git a/test/testmessage.c b/test/testmessage.c
index f76b7eb..3304623 100644
--- a/test/testmessage.c
+++ b/test/testmessage.c
@@ -62,7 +62,7 @@ button_messagebox(void *eventNumber)
success = SDL_ShowMessageBox(&data, &button);
if (success == -1) {
- printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
if (eventNumber) {
SDL_UserEvent event;
event.type = (intptr_t)eventNumber;
@@ -72,7 +72,7 @@ button_messagebox(void *eventNumber)
quit(2);
}
}
- printf("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
+ SDL_Log("Pressed button: %d, %s\n", button, button == 1 ? "Cancel" : "OK");
if (eventNumber) {
SDL_UserEvent event;
@@ -88,12 +88,15 @@ main(int argc, char *argv[])
{
int success;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Simple MessageBox",
"This is a simple error MessageBox",
NULL);
if (success == -1) {
- printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -102,7 +105,7 @@ main(int argc, char *argv[])
"This is a simple MessageBox with a newline:\r\nHello world!",
NULL);
if (success == -1) {
- printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -112,7 +115,7 @@ main(int argc, char *argv[])
"Unicode text: '牛肉西è˜èŠ±' ...",
NULL);
if (success == -1) {
- printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -122,7 +125,7 @@ main(int argc, char *argv[])
"Unicode text and newline:\r\n'牛肉西è˜èŠ±'\n'牛肉西è˜èŠ±'",
NULL);
if (success == -1) {
- printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
@@ -135,7 +138,7 @@ main(int argc, char *argv[])
subsystem on the main thread.
*/
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
return (1);
}
{
@@ -153,7 +156,7 @@ main(int argc, char *argv[])
SDL_WaitThread(thread, &status);
- printf("Message box thread return %i\n", status);
+ SDL_Log("Message box thread return %i\n", status);
}
/* Test showing a message box with a parent window */
@@ -166,7 +169,7 @@ main(int argc, char *argv[])
"This is a simple error MessageBox with a parent window",
window);
if (success == -1) {
- printf("Error Presenting MessageBox: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error Presenting MessageBox: %s\n", SDL_GetError());
quit(1);
}
diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c
index 47a95e3..48d628a 100644
--- a/test/testmultiaudio.c
+++ b/test/testmultiaudio.c
@@ -10,7 +10,6 @@
freely.
*/
#include "SDL.h"
-#include <stdio.h>
static SDL_AudioSpec spec;
static Uint8 *sound = NULL; /* Pointer to wave data */
@@ -51,7 +50,7 @@ test_multi_audio(int devcount)
int i;
if (devcount > 64) {
- fprintf(stderr, "Too many devices (%d), clamping to 64...\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Too many devices (%d), clamping to 64...\n",
devcount);
devcount = 64;
}
@@ -60,33 +59,33 @@ test_multi_audio(int devcount)
for (i = 0; i < devcount; i++) {
const char *devname = SDL_GetAudioDeviceName(i, 0);
- printf("playing on device #%d: ('%s')...", i, devname);
+ SDL_Log("playing on device #%d: ('%s')...", i, devname);
fflush(stdout);
SDL_memset(&cbd[0], '\0', sizeof(callback_data));
spec.userdata = &cbd[0];
cbd[0].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
if (cbd[0].dev == 0) {
- printf("\nOpen device failed: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device failed: %s\n", SDL_GetError());
} else {
SDL_PauseAudioDevice(cbd[0].dev, 0);
while (!cbd[0].done)
SDL_Delay(100);
SDL_PauseAudioDevice(cbd[0].dev, 1);
- printf("done.\n");
+ SDL_Log("done.\n");
SDL_CloseAudioDevice(cbd[0].dev);
}
}
SDL_memset(cbd, '\0', sizeof(cbd));
- printf("playing on all devices...\n");
+ SDL_Log("playing on all devices...\n");
for (i = 0; i < devcount; i++) {
const char *devname = SDL_GetAudioDeviceName(i, 0);
spec.userdata = &cbd[i];
cbd[i].dev = SDL_OpenAudioDevice(devname, 0, &spec, NULL, 0);
if (cbd[i].dev == 0) {
- printf("Open device %d failed: %s\n", i, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open device %d failed: %s\n", i, SDL_GetError());
}
}
@@ -113,7 +112,7 @@ test_multi_audio(int devcount)
}
}
- printf("All done!\n");
+ SDL_Log("All done!\n");
}
@@ -122,17 +121,20 @@ main(int argc, char **argv)
{
int devcount = 0;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
- printf("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
+ SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
devcount = SDL_GetNumAudioDevices(0);
if (devcount < 1) {
- fprintf(stderr, "Don't see any specific audio devices!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!\n");
} else {
if (argv[1] == NULL) {
argv[1] = "sample.wav";
@@ -140,7 +142,7 @@ main(int argc, char **argv)
/* Load the wave file into memory */
if (SDL_LoadWAV(argv[1], &spec, &sound, &soundlen) == NULL) {
- fprintf(stderr, "Couldn't load %s: %s\n", argv[1],
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1],
SDL_GetError());
} else {
test_multi_audio(devcount);
diff --git a/test/testnative.c b/test/testnative.c
index 63cba29..0ac99b2 100644
--- a/test/testnative.c
+++ b/test/testnative.c
@@ -58,7 +58,7 @@ LoadSprite(SDL_Renderer *renderer, char *file)
/* Load the sprite image */
temp = SDL_LoadBMP(file);
if (temp == NULL) {
- fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
return 0;
}
@@ -70,7 +70,7 @@ LoadSprite(SDL_Renderer *renderer, char *file)
/* Create textures from the image */
sprite = SDL_CreateTextureFromSurface(renderer, temp);
if (!sprite) {
- fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
return 0;
}
@@ -131,8 +131,11 @@ main(int argc, char *argv[])
int sprite_w, sprite_h;
SDL_Event event;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_VideoInit(NULL) < 0) {
- fprintf(stderr, "Couldn't initialize SDL video: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
SDL_GetError());
exit(1);
}
@@ -146,19 +149,19 @@ main(int argc, char *argv[])
}
}
if (!factory) {
- fprintf(stderr, "Couldn't find native window code for %s driver\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n",
driver);
quit(2);
}
- printf("Creating native window for %s driver\n", driver);
+ SDL_Log("Creating native window for %s driver\n", driver);
native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H);
if (!native_window) {
- fprintf(stderr, "Couldn't create native window\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n");
quit(3);
}
window = SDL_CreateWindowFrom(native_window);
if (!window) {
- fprintf(stderr, "Couldn't create SDL window: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError());
quit(4);
}
SDL_SetWindowTitle(window, "SDL Native Window Test");
@@ -166,7 +169,7 @@ main(int argc, char *argv[])
/* Create the renderer */
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
- fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
quit(5);
}
@@ -185,7 +188,7 @@ main(int argc, char *argv[])
positions = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
velocities = (SDL_Rect *) SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect));
if (!positions || !velocities) {
- fprintf(stderr, "Out of memory!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
srand(time(NULL));
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
index e071614..23e1e1f 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -209,19 +209,18 @@ ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h,
static void
PrintUsage(char *argv0)
{
- fprintf(stderr, "Usage: %s [arg] [arg] [arg] ...\n", argv0);
- fprintf(stderr, "\n");
- fprintf(stderr, "Where 'arg' is any of the following options:\n");
- fprintf(stderr, "\n");
- fprintf(stderr, " -fps <frames per second>\n");
- fprintf(stderr, " -nodelay\n");
- fprintf(stderr, " -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
- fprintf(stderr, " -scale <scale factor> (initial scale of the overlay)\n");
- fprintf(stderr, " -help (shows this help)\n");
- fprintf(stderr, "\n");
- fprintf(stderr,
- "Press ESC to exit, or SPACE to freeze the movie while application running.\n");
- fprintf(stderr, "\n");
+ SDL_Log("Usage: %s [arg] [arg] [arg] ...\n", argv0);
+ SDL_Log("\n");
+ SDL_Log("Where 'arg' is any of the following options:\n");
+ SDL_Log("\n");
+ SDL_Log(" -fps <frames per second>\n");
+ SDL_Log(" -nodelay\n");
+ SDL_Log(" -format <fmt> (one of the: YV12, IYUV, YUY2, UYVY, YVYU)\n");
+ SDL_Log(" -scale <scale factor> (initial scale of the overlay)\n");
+ SDL_Log(" -help (shows this help)\n");
+ SDL_Log("\n");
+ SDL_Log("Press ESC to exit, or SPACE to freeze the movie while application running.\n");
+ SDL_Log("\n");
}
int
@@ -246,8 +245,11 @@ main(int argc, char **argv)
int scale = 5;
SDL_bool done = SDL_FALSE;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 3;
}
@@ -256,19 +258,19 @@ main(int argc, char **argv)
if (argv[2]) {
fps = atoi(argv[2]);
if (fps == 0) {
- fprintf(stderr,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"The -fps option requires an argument [from 1 to 1000], default is 12.\n");
quit(10);
}
if ((fps < 0) || (fps > 1000)) {
- fprintf(stderr,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"The -fps option must be in range from 1 to 1000, default is 12.\n");
quit(10);
}
argv += 2;
argc -= 2;
} else {
- fprintf(stderr,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"The -fps option requires an argument [from 1 to 1000], default is 12.\n");
quit(10);
}
@@ -280,19 +282,19 @@ main(int argc, char **argv)
if (argv[2]) {
scale = atoi(argv[2]);
if (scale == 0) {
- fprintf(stderr,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"The -scale option requires an argument [from 1 to 50], default is 5.\n");
quit(10);
}
if ((scale < 0) || (scale > 50)) {
- fprintf(stderr,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"The -scale option must be in range from 1 to 50, default is 5.\n");
quit(10);
}
argv += 2;
argc -= 2;
} else {
- fprintf(stderr,
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"The -fps option requires an argument [from 1 to 1000], default is 12.\n");
quit(10);
}
@@ -301,7 +303,7 @@ main(int argc, char **argv)
PrintUsage(argv[0]);
quit(0);
} else {
- fprintf(stderr, "Unrecognized option: %s.\n", argv[1]);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unrecognized option: %s.\n", argv[1]);
quit(10);
}
break;
@@ -309,7 +311,7 @@ main(int argc, char **argv)
RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
if (RawMooseData == NULL) {
- fprintf(stderr, "Can't allocate memory for movie !\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
free(RawMooseData);
quit(1);
}
@@ -317,7 +319,7 @@ main(int argc, char **argv)
/* load the trojan moose images */
handle = SDL_RWFromFile("moose.dat", "rb");
if (handle == NULL) {
- fprintf(stderr, "Can't find the file moose.dat !\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
free(RawMooseData);
quit(2);
}
@@ -335,21 +337,21 @@ main(int argc, char **argv)
window_w, window_h,
SDL_WINDOW_RESIZABLE);
if (!window) {
- fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
free(RawMooseData);
quit(4);
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
- fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
free(RawMooseData);
quit(4);
}
MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (!MooseTexture) {
- fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
free(RawMooseData);
quit(5);
}
diff --git a/test/testplatform.c b/test/testplatform.c
index 326b6f7..2f32e1f 100644
--- a/test/testplatform.c
+++ b/test/testplatform.c
@@ -35,30 +35,30 @@ TestTypes(SDL_bool verbose)
if (badsize(sizeof(Uint8), 1)) {
if (verbose)
- printf("sizeof(Uint8) != 1, instead = %u\n",
+ SDL_Log("sizeof(Uint8) != 1, instead = %u\n",
(unsigned int)sizeof(Uint8));
++error;
}
if (badsize(sizeof(Uint16), 2)) {
if (verbose)
- printf("sizeof(Uint16) != 2, instead = %u\n",
+ SDL_Log("sizeof(Uint16) != 2, instead = %u\n",
(unsigned int)sizeof(Uint16));
++error;
}
if (badsize(sizeof(Uint32), 4)) {
if (verbose)
- printf("sizeof(Uint32) != 4, instead = %u\n",
+ SDL_Log("sizeof(Uint32) != 4, instead = %u\n",
(unsigned int)sizeof(Uint32));
++error;
}
if (badsize(sizeof(Uint64), 8)) {
if (verbose)
- printf("sizeof(Uint64) != 8, instead = %u\n",
+ SDL_Log("sizeof(Uint64) != 8, instead = %u\n",
(unsigned int)sizeof(Uint64));
++error;
}
if (verbose && !error)
- printf("All data types are the expected size.\n");
+ SDL_Log("All data types are the expected size.\n");
return (error ? 1 : 0);
}
@@ -83,7 +83,7 @@ TestEndian(SDL_bool verbose)
swapped64 |= 0xDEADBEEF;
if (verbose) {
- printf("Detected a %s endian machine.\n",
+ SDL_Log("Detected a %s endian machine.\n",
(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
}
if ((*((char *) &value) >> 4) == 0x1) {
@@ -93,44 +93,44 @@ TestEndian(SDL_bool verbose)
}
if (real_byteorder != SDL_BYTEORDER) {
if (verbose) {
- printf("Actually a %s endian machine!\n",
+ SDL_Log("Actually a %s endian machine!\n",
(real_byteorder == SDL_LIL_ENDIAN) ? "little" : "big");
}
++error;
}
if (verbose) {
- printf("Value 16 = 0x%X, swapped = 0x%X\n", value16,
+ SDL_Log("Value 16 = 0x%X, swapped = 0x%X\n", value16,
SDL_Swap16(value16));
}
if (SDL_Swap16(value16) != swapped16) {
if (verbose) {
- printf("16 bit value swapped incorrectly!\n");
+ SDL_Log("16 bit value swapped incorrectly!\n");
}
++error;
}
if (verbose) {
- printf("Value 32 = 0x%X, swapped = 0x%X\n", value32,
+ SDL_Log("Value 32 = 0x%X, swapped = 0x%X\n", value32,
SDL_Swap32(value32));
}
if (SDL_Swap32(value32) != swapped32) {
if (verbose) {
- printf("32 bit value swapped incorrectly!\n");
+ SDL_Log("32 bit value swapped incorrectly!\n");
}
++error;
}
if (verbose) {
#ifdef _MSC_VER
- printf("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
+ SDL_Log("Value 64 = 0x%I64X, swapped = 0x%I64X\n", value64,
SDL_Swap64(value64));
#else
- printf("Value 64 = 0x%llX, swapped = 0x%llX\n",
+ SDL_Log("Value 64 = 0x%llX, swapped = 0x%llX\n",
(unsigned long long) value64,
(unsigned long long) SDL_Swap64(value64));
#endif
}
if (SDL_Swap64(value64) != swapped64) {
if (verbose) {
- printf("64 bit value swapped incorrectly!\n");
+ SDL_Log("64 bit value swapped incorrectly!\n");
}
++error;
}
@@ -142,17 +142,17 @@ int
TestCPUInfo(SDL_bool verbose)
{
if (verbose) {
- printf("CPU count: %d\n", SDL_GetCPUCount());
- printf("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
- printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
- printf("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
- printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
- printf("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
- printf("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
- printf("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
- printf("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
- printf("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
- printf("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
+ SDL_Log("CPU count: %d\n", SDL_GetCPUCount());
+ SDL_Log("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
+ SDL_Log("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
+ SDL_Log("AltiVec %s\n", SDL_HasAltiVec()? "detected" : "not detected");
+ SDL_Log("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
+ SDL_Log("3DNow! %s\n", SDL_Has3DNow()? "detected" : "not detected");
+ SDL_Log("SSE %s\n", SDL_HasSSE()? "detected" : "not detected");
+ SDL_Log("SSE2 %s\n", SDL_HasSSE2()? "detected" : "not detected");
+ SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected");
+ SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected");
+ SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected");
}
return (0);
}
@@ -176,7 +176,7 @@ TestAssertions(SDL_bool verbose)
{
const SDL_assert_data *item = SDL_GetAssertionReport();
while (item) {
- printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
+ SDL_Log("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n",
item->condition, item->function, item->filename,
item->linenum, item->trigger_count,
item->always_ignore ? "yes" : "no");
@@ -192,11 +192,14 @@ main(int argc, char *argv[])
SDL_bool verbose = SDL_TRUE;
int status = 0;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (argv[1] && (SDL_strcmp(argv[1], "-q") == 0)) {
verbose = SDL_FALSE;
}
if (verbose) {
- printf("This system is running %s\n", SDL_GetPlatform());
+ SDL_Log("This system is running %s\n", SDL_GetPlatform());
}
status += TestTypes(verbose);
diff --git a/test/testpower.c b/test/testpower.c
index 3e13d0a..1b32143 100644
--- a/test/testpower.c
+++ b/test/testpower.c
@@ -21,7 +21,7 @@ report_power(void)
const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
char *statestr = NULL;
- printf("SDL-reported power info...\n");
+ SDL_Log("SDL-reported power info...\n");
switch (state) {
case SDL_POWERSTATE_UNKNOWN:
statestr = "Unknown";
@@ -43,18 +43,18 @@ report_power(void)
break;
}
- printf("State: %s\n", statestr);
+ SDL_Log("State: %s\n", statestr);
if (percent == -1) {
- printf("Percent left: unknown\n");
+ SDL_Log("Percent left: unknown\n");
} else {
- printf("Percent left: %d%%\n", percent);
+ SDL_Log("Percent left: %d%%\n", percent);
}
if (seconds == -1) {
- printf("Time left: unknown\n");
+ SDL_Log("Time left: unknown\n");
} else {
- printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
+ SDL_Log("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
(int) (seconds % 60));
}
}
@@ -63,8 +63,11 @@ report_power(void)
int
main(int argc, char *argv[])
{
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_Init(0) == -1) {
- fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
return 1;
}
diff --git a/test/testrelative.c b/test/testrelative.c
index fa5bda6..478d3bf 100644
--- a/test/testrelative.c
+++ b/test/testrelative.c
@@ -35,6 +35,8 @@ main(int argc, char *argv[])
int i, done;
SDL_Event event;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
@@ -74,10 +76,8 @@ main(int argc, char *argv[])
switch(event.type) {
case SDL_MOUSEMOTION:
{
- /*printf("mouse motion ABS x %d y %d REL x %d y %d\n",event.motion.x,event.motion.y,event.motion.xrel,event.motion.yrel);*/
rect.x += event.motion.xrel;
rect.y += event.motion.yrel;
-
}
break;
}
diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c
index 6dd59c0..a0221fe 100644
--- a/test/testrendercopyex.c
+++ b/test/testrendercopyex.c
@@ -46,7 +46,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
/* Load the sprite image */
temp = SDL_LoadBMP(file);
if (temp == NULL) {
- fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
return NULL;
}
@@ -77,7 +77,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
/* Create textures from the image */
texture = SDL_CreateTextureFromSurface(renderer, temp);
if (!texture) {
- fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
return NULL;
}
@@ -139,6 +139,9 @@ main(int argc, char *argv[])
int frames;
Uint32 then, now;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
@@ -149,7 +152,7 @@ main(int argc, char *argv[])
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
- fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+ SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
return 1;
}
i += consumed;
@@ -193,7 +196,7 @@ main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
- printf("%2.2f frames per second\n", fps);
+ SDL_Log("%2.2f frames per second\n", fps);
}
SDL_stack_free(drawstates);
diff --git a/test/testrendertarget.c b/test/testrendertarget.c
index bc31048..03e8df1 100644
--- a/test/testrendertarget.c
+++ b/test/testrendertarget.c
@@ -46,7 +46,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
/* Load the sprite image */
temp = SDL_LoadBMP(file);
if (temp == NULL) {
- fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
return NULL;
}
@@ -77,7 +77,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
/* Create textures from the image */
texture = SDL_CreateTextureFromSurface(renderer, temp);
if (!texture) {
- fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
return NULL;
}
@@ -114,7 +114,7 @@ DrawComposite(DrawState *s)
SDL_RenderCopy(s->renderer, A, NULL, NULL);
SDL_RenderReadPixels(s->renderer, NULL, SDL_PIXELFORMAT_ARGB8888, &P, sizeof(P));
- printf("Blended pixel: 0x%8.8X\n", P);
+ SDL_Log("Blended pixel: 0x%8.8X\n", P);
SDL_DestroyTexture(A);
SDL_DestroyTexture(B);
@@ -218,6 +218,9 @@ main(int argc, char *argv[])
Uint32 then, now;
SDL_bool test_composite = SDL_FALSE;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
@@ -235,8 +238,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr,
- "Usage: %s %s [--composite]\n",
+ SDL_Log("Usage: %s %s [--composite]\n",
argv[0], SDLTest_CommonUsage(state));
quit(1);
}
@@ -289,7 +291,7 @@ main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
- printf("%2.2f frames per second\n", fps);
+ SDL_Log("%2.2f frames per second\n", fps);
}
SDL_stack_free(drawstates);
diff --git a/test/testresample.c b/test/testresample.c
index d79f1ac..177bd84 100644
--- a/test/testresample.c
+++ b/test/testresample.c
@@ -9,7 +9,7 @@
including commercial applications, and to alter it and redistribute it
freely.
*/
-#include <stdio.h>
+
#include "SDL.h"
int
@@ -25,27 +25,30 @@ main(int argc, char **argv)
int avgbytes = 0;
SDL_RWops *io = NULL;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (argc != 4) {
- fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]);
+ SDL_Log("USAGE: %s in.wav out.wav newfreq\n", argv[0]);
return 1;
}
cvtfreq = SDL_atoi(argv[3]);
if (SDL_Init(SDL_INIT_AUDIO) == -1) {
- fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
return 2;
}
if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) {
- fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", argv[1], SDL_GetError());
SDL_Quit();
return 3;
}
if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
spec.format, spec.channels, cvtfreq) == -1) {
- fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to build CVT: %s\n", SDL_GetError());
SDL_FreeWAV(data);
SDL_Quit();
return 4;
@@ -54,7 +57,7 @@ main(int argc, char **argv)
cvt.len = len;
cvt.buf = (Uint8 *) SDL_malloc(len * cvt.len_mult);
if (cvt.buf == NULL) {
- fprintf(stderr, "Out of memory.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n");
SDL_FreeWAV(data);
SDL_Quit();
return 5;
@@ -62,7 +65,7 @@ main(int argc, char **argv)
SDL_memcpy(cvt.buf, data, len);
if (SDL_ConvertAudio(&cvt) == -1) {
- fprintf(stderr, "Conversion failed: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Conversion failed: %s\n", SDL_GetError());
SDL_free(cvt.buf);
SDL_FreeWAV(data);
SDL_Quit();
@@ -72,7 +75,7 @@ main(int argc, char **argv)
/* write out a WAV header... */
io = SDL_RWFromFile(argv[2], "wb");
if (io == NULL) {
- fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
SDL_free(cvt.buf);
SDL_FreeWAV(data);
SDL_Quit();
@@ -99,7 +102,7 @@ main(int argc, char **argv)
SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
if (SDL_RWclose(io) == -1) {
- fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
SDL_free(cvt.buf);
SDL_FreeWAV(data);
SDL_Quit();
diff --git a/test/testrumble.c b/test/testrumble.c
index e5b5424..ffcaae4 100644
--- a/test/testrumble.c
+++ b/test/testrumble.c
@@ -26,7 +26,6 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* includes
*/
#include <stdlib.h>
-#include <stdio.h> /* printf */
#include <string.h> /* strstr */
#include <ctype.h> /* isdigit */
@@ -51,12 +50,15 @@ main(int argc, char **argv)
char *name;
int index;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
name = NULL;
index = -1;
if (argc > 1) {
name = argv[1];
if ((strcmp(name, "--help") == 0) || (strcmp(name, "-h") == 0)) {
- printf("USAGE: %s [device]\n"
+ SDL_Log("USAGE: %s [device]\n"
"If device is a two-digit number it'll use it as an index, otherwise\n"
"it'll use it as if it were part of the device's name.\n",
argv[0]);
@@ -73,7 +75,7 @@ main(int argc, char **argv)
/* Initialize the force feedbackness */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK |
SDL_INIT_HAPTIC);
- printf("%d Haptic devices detected.\n", SDL_NumHaptics());
+ SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics());
if (SDL_NumHaptics() > 0) {
/* We'll just use index or the first force feedback device found */
if (name == NULL) {
@@ -87,7 +89,7 @@ main(int argc, char **argv)
}
if (i >= SDL_NumHaptics()) {
- printf("Unable to find device matching '%s', aborting.\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to find device matching '%s', aborting.\n",
name);
return 1;
}
@@ -95,13 +97,13 @@ main(int argc, char **argv)
haptic = SDL_HapticOpen(i);
if (haptic == NULL) {
- printf("Unable to create the haptic device: %s\n",
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n",
SDL_GetError());
return 1;
}
- printf("Device: %s\n", SDL_HapticName(i));
+ SDL_Log("Device: %s\n", SDL_HapticName(i));
} else {
- printf("No Haptic devices found!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No Haptic devices found!\n");
return 1;
}
@@ -109,25 +111,25 @@ main(int argc, char **argv)
SDL_ClearError();
if (SDL_HapticRumbleSupported(haptic) == SDL_FALSE) {
- printf("\nRumble not supported!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
return 1;
}
if (SDL_HapticRumbleInit(haptic) != 0) {
- printf("\nFailed to initialize rumble: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
return 1;
}
- printf("Playing 2 second rumble at 0.5 magnitude.\n");
+ SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
if (SDL_HapticRumblePlay(haptic, 0.5, 5000) != 0) {
- printf("\nFailed to play rumble: %s\n", SDL_GetError() );
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() );
return 1;
}
SDL_Delay(2000);
- printf("Stopping rumble.\n");
+ SDL_Log("Stopping rumble.\n");
SDL_HapticRumbleStop(haptic);
SDL_Delay(2000);
- printf("Playing 2 second rumble at 0.3 magnitude.\n");
+ SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
if (SDL_HapticRumblePlay(haptic, 0.3f, 5000) != 0) {
- printf("\nFailed to play rumble: %s\n", SDL_GetError() );
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError() );
return 1;
}
SDL_Delay(2000);
@@ -145,7 +147,7 @@ main(int argc, char **argv)
int
main(int argc, char *argv[])
{
- fprintf(stderr, "SDL compiled without Haptic support.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Haptic support.\n");
exit(1);
}
diff --git a/test/testscale.c b/test/testscale.c
index 0f0096c..f81ccdc 100644
--- a/test/testscale.c
+++ b/test/testscale.c
@@ -48,7 +48,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
/* Load the sprite image */
temp = SDL_LoadBMP(file);
if (temp == NULL) {
- fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
return NULL;
}
@@ -79,7 +79,7 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent)
/* Create textures from the image */
texture = SDL_CreateTextureFromSurface(renderer, temp);
if (!texture) {
- fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
return NULL;
}
@@ -129,6 +129,9 @@ main(int argc, char *argv[])
int frames;
Uint32 then, now;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
@@ -139,7 +142,7 @@ main(int argc, char *argv[])
consumed = SDLTest_CommonArg(state, i);
if (consumed == 0) {
- fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+ SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
return 1;
}
i += consumed;
@@ -183,7 +186,7 @@ main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
- printf("%2.2f frames per second\n", fps);
+ SDL_Log("%2.2f frames per second\n", fps);
}
SDL_stack_free(drawstates);
diff --git a/test/testsem.c b/test/testsem.c
index eab280e..6a2a59e 100644
--- a/test/testsem.c
+++ b/test/testsem.c
@@ -30,17 +30,15 @@ ThreadFunc(void *data)
int threadnum = (int) (uintptr_t) data;
while (alive) {
SDL_SemWait(sem);
- fprintf(stderr,
- "Thread number %d has got the semaphore (value = %d)!\n",
+ SDL_Log("Thread number %d has got the semaphore (value = %d)!\n",
threadnum, SDL_SemValue(sem));
SDL_Delay(200);
SDL_SemPost(sem);
- fprintf(stderr,
- "Thread number %d has released the semaphore (value = %d)!\n",
+ SDL_Log("Thread number %d has released the semaphore (value = %d)!\n",
threadnum, SDL_SemValue(sem));
SDL_Delay(1); /* For the scheduler */
}
- printf("Thread number %d exiting.\n", threadnum);
+ SDL_Log("Thread number %d exiting.\n", threadnum);
return 0;
}
@@ -59,7 +57,7 @@ TestWaitTimeout(void)
int retval;
sem = SDL_CreateSemaphore(0);
- printf("Waiting 2 seconds on semaphore\n");
+ SDL_Log("Waiting 2 seconds on semaphore\n");
start_ticks = SDL_GetTicks();
retval = SDL_SemWaitTimeout(sem, 2000);
@@ -69,13 +67,13 @@ TestWaitTimeout(void)
/* Accept a little offset in the effective wait */
if (duration > 1900 && duration < 2050)
- printf("Wait done.\n");
+ SDL_Log("Wait done.\n");
else
- fprintf(stderr, "Wait took %d milliseconds\n", duration);
+ SDL_Log("Wait took %d milliseconds\n", duration);
/* Check to make sure the return value indicates timed out */
if (retval != SDL_MUTEX_TIMEDOUT)
- fprintf(stderr, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT);
}
int
@@ -85,14 +83,17 @@ main(int argc, char **argv)
uintptr_t i;
int init_sem;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (argc < 2) {
- fprintf(stderr, "Usage: %s init_value\n", argv[0]);
+ SDL_Log("Usage: %s init_value\n", argv[0]);
return (1);
}
/* Load the SDL library */
if (SDL_Init(0) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
signal(SIGTERM, killed);
@@ -101,7 +102,7 @@ main(int argc, char **argv)
init_sem = atoi(argv[1]);
sem = SDL_CreateSemaphore(init_sem);
- printf("Running %d threads, semaphore value = %d\n", NUM_THREADS,
+ SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS,
init_sem);
/* Create all the threads */
for (i = 0; i < NUM_THREADS; ++i) {
@@ -114,12 +115,12 @@ main(int argc, char **argv)
SDL_Delay(10 * 1000);
/* Wait for all threads to finish */
- printf("Waiting for threads to finish\n");
+ SDL_Log("Waiting for threads to finish\n");
alive = 0;
for (i = 0; i < NUM_THREADS; ++i) {
SDL_WaitThread(threads[i], NULL);
}
- printf("Finished waiting for threads\n");
+ SDL_Log("Finished waiting for threads\n");
SDL_DestroySemaphore(sem);
diff --git a/test/testshader.c b/test/testshader.c
index 376b445..138dd45 100644
--- a/test/testshader.c
+++ b/test/testshader.c
@@ -11,7 +11,6 @@
*/
/* This is a simple example of using GLSL shaders with SDL */
-#include <stdio.h> /* for printf() */
#include "SDL.h"
#ifdef HAVE_OPENGL
@@ -139,7 +138,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source)
glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = SDL_stack_alloc(char, length+1);
glGetInfoLogARB(shader, length, NULL, info);
- fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info);
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
SDL_stack_free(info);
return SDL_FALSE;
@@ -245,7 +244,7 @@ static SDL_bool InitShaders()
/* Compile all the shaders */
for (i = 0; i < NUM_SHADERS; ++i) {
if (!CompileShaderProgram(&shaders[i])) {
- fprintf(stderr, "Unable to compile shader!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
return SDL_FALSE;
}
}
@@ -422,29 +421,32 @@ int main(int argc, char **argv)
GLuint texture;
GLfloat texcoords[4];
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Initialize SDL for video output */
if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
- fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
exit(1);
}
/* Create a 640x480 OpenGL screen */
window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL );
if ( !window ) {
- fprintf(stderr, "Unable to create OpenGL window: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}
if ( !SDL_GL_CreateContext(window)) {
- fprintf(stderr, "Unable to create OpenGL context: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
SDL_Quit();
exit(2);
}
surface = SDL_LoadBMP("icon.bmp");
if ( ! surface ) {
- fprintf(stderr, "Unable to load icon.bmp: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
SDL_Quit();
exit(3);
}
@@ -454,9 +456,9 @@ int main(int argc, char **argv)
/* Loop, drawing and checking events */
InitGL(640, 480);
if (InitShaders()) {
- printf("Shaders supported, press SPACE to cycle them.\n");
+ SDL_Log("Shaders supported, press SPACE to cycle them.\n");
} else {
- printf("Shaders not supported!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
}
done = 0;
while ( ! done ) {
@@ -489,7 +491,7 @@ int main(int argc, char **argv)
int
main(int argc, char *argv[])
{
- printf("No OpenGL support on this system\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
return 1;
}
diff --git a/test/testshape.c b/test/testshape.c
index 59dfb9f..5c969b3 100644
--- a/test/testshape.c
+++ b/test/testshape.c
@@ -68,13 +68,16 @@ int main(int argc,char** argv)
int access = 0;
SDL_Rect texture_dimensions;;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if(argc < 2) {
- printf("SDL_Shape requires at least one bitmap file as argument.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Shape requires at least one bitmap file as argument.");
exit(-1);
}
if(SDL_VideoInit(NULL) == -1) {
- printf("Could not initialize SDL video.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video.");
exit(-2);
}
@@ -91,7 +94,7 @@ int main(int argc,char** argv)
SDL_FreeSurface(pictures[j].surface);
SDL_free(pictures);
SDL_VideoQuit();
- printf("Could not load surface from named bitmap file.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file.");
exit(-3);
}
@@ -112,7 +115,7 @@ int main(int argc,char** argv)
SDL_FreeSurface(pictures[i].surface);
SDL_free(pictures);
SDL_VideoQuit();
- printf("Could not create shaped window for SDL_Shape.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
exit(-4);
}
renderer = SDL_CreateRenderer(window,-1,0);
@@ -122,7 +125,7 @@ int main(int argc,char** argv)
SDL_FreeSurface(pictures[i].surface);
SDL_free(pictures);
SDL_VideoQuit();
- printf("Could not create rendering context for SDL_Shape window.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
exit(-5);
}
@@ -141,7 +144,7 @@ int main(int argc,char** argv)
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_VideoQuit();
- printf("Could not create texture for SDL_shape.\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
exit(-6);
}
}
diff --git a/test/testsprite2.c b/test/testsprite2.c
index f772969..26cc29f 100644
--- a/test/testsprite2.c
+++ b/test/testsprite2.c
@@ -64,7 +64,7 @@ LoadSprite(const char *file)
/* Load the sprite image */
temp = SDL_LoadBMP(file);
if (temp == NULL) {
- fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError());
return (-1);
}
sprite_w = temp->w;
@@ -95,7 +95,7 @@ LoadSprite(const char *file)
SDL_Renderer *renderer = state->renderers[i];
sprites[i] = SDL_CreateTextureFromSurface(renderer, temp);
if (!sprites[i]) {
- fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
return (-1);
}
@@ -299,8 +299,7 @@ main(int argc, char *argv[])
}
}
if (consumed < 0) {
- fprintf(stderr,
- "Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n",
+ SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n",
argv[0], SDLTest_CommonUsage(state));
quit(1);
}
@@ -314,7 +313,7 @@ main(int argc, char *argv[])
sprites =
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
if (!sprites) {
- fprintf(stderr, "Out of memory!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
for (i = 0; i < state->num_windows; ++i) {
@@ -330,7 +329,7 @@ main(int argc, char *argv[])
positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect));
if (!positions || !velocities) {
- fprintf(stderr, "Out of memory!\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
@@ -375,7 +374,7 @@ main(int argc, char *argv[])
now = SDL_GetTicks();
if (now > then) {
double fps = ((double) frames * 1000) / (now - then);
- printf("%2.2f frames per second\n", fps);
+ SDL_Log("%2.2f frames per second\n", fps);
}
quit(0);
return 0;
diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c
index 6f3ac25..157293f 100644
--- a/test/testspriteminimal.c
+++ b/test/testspriteminimal.c
@@ -42,7 +42,7 @@ LoadSprite(char *file, SDL_Renderer *renderer)
/* Load the sprite image */
temp = SDL_LoadBMP(file);
if (temp == NULL) {
- fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", file, SDL_GetError());
return (-1);
}
sprite_w = temp->w;
@@ -73,7 +73,7 @@ LoadSprite(char *file, SDL_Renderer *renderer)
/* Create textures from the image */
sprite = SDL_CreateTextureFromSurface(renderer, temp);
if (!sprite) {
- fprintf(stderr, "Couldn't create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError());
SDL_FreeSurface(temp);
return (-1);
}
@@ -126,6 +126,9 @@ main(int argc, char *argv[])
int i, done;
SDL_Event event;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_CreateWindowAndRenderer(WINDOW_WIDTH, WINDOW_HEIGHT, 0, &window, &renderer) < 0) {
quit(2);
}
diff --git a/test/teststreaming.c b/test/teststreaming.c
index ea3ac2d..1d3f682 100644
--- a/test/teststreaming.c
+++ b/test/teststreaming.c
@@ -68,7 +68,7 @@ void UpdateTexture(SDL_Texture *texture, int frame)
int pitch;
if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
- fprintf(stderr, "Couldn't lock texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
quit(5);
}
src = MooseFrames[frame];
@@ -93,15 +93,18 @@ main(int argc, char **argv)
SDL_bool done = SDL_FALSE;
int frame;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
/* load the moose images */
handle = SDL_RWFromFile("moose.dat", "rb");
if (handle == NULL) {
- fprintf(stderr, "Can't find the file moose.dat !\n");
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
quit(2);
}
SDL_RWread(handle, MooseFrames, MOOSEFRAME_SIZE, MOOSEFRAMES_COUNT);
@@ -115,19 +118,19 @@ main(int argc, char **argv)
MOOSEPIC_W*4, MOOSEPIC_H*4,
SDL_WINDOW_RESIZABLE);
if (!window) {
- fprintf(stderr, "Couldn't set create window: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());
quit(3);
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
- fprintf(stderr, "Couldn't set create renderer: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());
quit(4);
}
MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (!MooseTexture) {
- fprintf(stderr, "Couldn't set create texture: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
quit(5);
}
diff --git a/test/testthread.c b/test/testthread.c
index 949e44e..ed9f1f1 100644
--- a/test/testthread.c
+++ b/test/testthread.c
@@ -34,20 +34,20 @@ int SDLCALL
ThreadFunc(void *data)
{
SDL_TLSSet(tls, "baby thread", NULL);
- printf("Started thread %s: My thread id is %lu, thread data = %s\n",
+ SDL_Log("Started thread %s: My thread id is %lu, thread data = %s\n",
(char *) data, SDL_ThreadID(), (const char *)SDL_TLSGet(tls));
while (alive) {
- printf("Thread '%s' is alive!\n", (char *) data);
+ SDL_Log("Thread '%s' is alive!\n", (char *) data);
SDL_Delay(1 * 1000);
}
- printf("Thread '%s' exiting!\n", (char *) data);
+ SDL_Log("Thread '%s' exiting!\n", (char *) data);
return (0);
}
static void
killed(int sig)
{
- printf("Killed with SIGTERM, waiting 5 seconds to exit\n");
+ SDL_Log("Killed with SIGTERM, waiting 5 seconds to exit\n");
SDL_Delay(5 * 1000);
alive = 0;
quit(0);
@@ -58,35 +58,38 @@ main(int argc, char *argv[])
{
SDL_Thread *thread;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(0) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
tls = SDL_TLSCreate();
SDL_assert(tls);
SDL_TLSSet(tls, "main thread", NULL);
- printf("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
+ SDL_Log("Main thread data initially: %s\n", (const char *)SDL_TLSGet(tls));
alive = 1;
thread = SDL_CreateThread(ThreadFunc, "One", "#1");
if (thread == NULL) {
- fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}
SDL_Delay(5 * 1000);
- printf("Waiting for thread #1\n");
+ SDL_Log("Waiting for thread #1\n");
alive = 0;
SDL_WaitThread(thread, NULL);
- printf("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
+ SDL_Log("Main thread data finally: %s\n", (const char *)SDL_TLSGet(tls));
alive = 1;
signal(SIGTERM, killed);
thread = SDL_CreateThread(ThreadFunc, "Two", "#2");
if (thread == NULL) {
- fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}
raise(SIGTERM);
diff --git a/test/testtimer.c b/test/testtimer.c
index ebc655d..ea985e2 100644
--- a/test/testtimer.c
+++ b/test/testtimer.c
@@ -33,7 +33,7 @@ ticktock(Uint32 interval, void *param)
static Uint32 SDLCALL
callback(Uint32 interval, void *param)
{
- printf("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
+ SDL_Log("Timer %d : param = %d\n", interval, (int) (uintptr_t) param);
return interval;
}
@@ -45,8 +45,11 @@ main(int argc, char *argv[])
Uint32 start32, now32;
Uint64 start, now;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
if (SDL_Init(SDL_INIT_TIMER) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
@@ -61,7 +64,7 @@ main(int argc, char *argv[])
t1 = SDL_AddTimer(desired, ticktock, NULL);
/* Wait 10 seconds */
- printf("Waiting 10 seconds\n");
+ SDL_Log("Waiting 10 seconds\n");
SDL_Delay(10 * 1000);
/* Stop the timer */
@@ -69,28 +72,27 @@ main(int argc, char *argv[])
/* Print the results */
if (ticks) {
- fprintf(stderr,
- "Timer resolution: desired = %d ms, actual = %f ms\n",
+ SDL_Log("Timer resolution: desired = %d ms, actual = %f ms\n",
desired, (double) (10 * 1000) / ticks);
}
/* Test multiple timers */
- printf("Testing multiple timers...\n");
+ SDL_Log("Testing multiple timers...\n");
t1 = SDL_AddTimer(100, callback, (void *) 1);
if (!t1)
- fprintf(stderr, "Could not create timer 1: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 1: %s\n", SDL_GetError());
t2 = SDL_AddTimer(50, callback, (void *) 2);
if (!t2)
- fprintf(stderr, "Could not create timer 2: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 2: %s\n", SDL_GetError());
t3 = SDL_AddTimer(233, callback, (void *) 3);
if (!t3)
- fprintf(stderr, "Could not create timer 3: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,"Could not create timer 3: %s\n", SDL_GetError());
/* Wait 10 seconds */
- printf("Waiting 10 seconds\n");
+ SDL_Log("Waiting 10 seconds\n");
SDL_Delay(10 * 1000);
- printf("Removing timer 1 and waiting 5 more seconds\n");
+ SDL_Log("Removing timer 1 and waiting 5 more seconds\n");
SDL_RemoveTimer(t1);
SDL_Delay(5 * 1000);
@@ -103,15 +105,15 @@ main(int argc, char *argv[])
ticktock(0, NULL);
}
now = SDL_GetPerformanceCounter();
- printf("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
+ SDL_Log("1 million iterations of ticktock took %f ms\n", (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
- printf("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
+ SDL_Log("Performance counter frequency: %llu\n", (unsigned long long) SDL_GetPerformanceFrequency());
start32 = SDL_GetTicks();
start = SDL_GetPerformanceCounter();
SDL_Delay(1000);
now = SDL_GetPerformanceCounter();
now32 = SDL_GetTicks();
- printf("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
+ SDL_Log("Delay 1 second = %d ms in ticks, %f ms according to performance counter\n", (now32-start32), (double)((now - start)*1000) / SDL_GetPerformanceFrequency());
SDL_Quit();
return (0);
diff --git a/test/testver.c b/test/testver.c
index ecfcdf3..cf3a545 100644
--- a/test/testver.c
+++ b/test/testver.c
@@ -26,17 +26,20 @@ main(int argc, char *argv[])
SDL_version compiled;
SDL_version linked;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
#if SDL_VERSION_ATLEAST(2, 0, 0)
- printf("Compiled with SDL 2.0 or newer\n");
+ SDL_Log("Compiled with SDL 2.0 or newer\n");
#else
- printf("Compiled with SDL older than 2.0\n");
+ SDL_Log("Compiled with SDL older than 2.0\n");
#endif
SDL_VERSION(&compiled);
- printf("Compiled version: %d.%d.%d.%d (%s)\n",
+ SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n",
compiled.major, compiled.minor, compiled.patch,
SDL_REVISION_NUMBER, SDL_REVISION);
SDL_GetVersion(&linked);
- printf("Linked version: %d.%d.%d.%d (%s)\n",
+ SDL_Log("Linked version: %d.%d.%d.%d (%s)\n",
linked.major, linked.minor, linked.patch,
SDL_GetRevisionNumber(), SDL_GetRevision());
SDL_Quit();
diff --git a/test/testwm2.c b/test/testwm2.c
index efe6ea4..241f826 100644
--- a/test/testwm2.c
+++ b/test/testwm2.c
@@ -48,6 +48,9 @@ main(int argc, char *argv[])
int system_cursor = -1;
SDL_Cursor *cursor = NULL;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
SDL_assert(SDL_arraysize(cursorNames) == SDL_NUM_SYSTEM_CURSORS);
/* Initialize test framework */
@@ -64,7 +67,7 @@ main(int argc, char *argv[])
consumed = -1;
}
if (consumed < 0) {
- fprintf(stderr, "Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
+ SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state));
quit(1);
}
i += consumed;
@@ -84,7 +87,7 @@ main(int argc, char *argv[])
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if (window) {
- printf("Window %d resized to %dx%d\n",
+ SDL_Log("Window %d resized to %dx%d\n",
event.window.windowID,
event.window.data1,
event.window.data2);
@@ -93,7 +96,7 @@ main(int argc, char *argv[])
if (event.window.event == SDL_WINDOWEVENT_MOVED) {
SDL_Window *window = SDL_GetWindowFromID(event.window.windowID);
if (window) {
- printf("Window %d moved to %d,%d (display %s)\n",
+ SDL_Log("Window %d moved to %d,%d (display %s)\n",
event.window.windowID,
event.window.data1,
event.window.data2,
diff --git a/test/torturethread.c b/test/torturethread.c
index 795b60b..53a57a9 100644
--- a/test/torturethread.c
+++ b/test/torturethread.c
@@ -49,7 +49,7 @@ ThreadFunc(void *data)
int i;
int tid = (int) (uintptr_t) data;
- fprintf(stderr, "Creating Thread %d\n", tid);
+ SDL_Log("Creating Thread %d\n", tid);
for (i = 0; i < NUMTHREADS; i++) {
char name[64];
@@ -58,18 +58,18 @@ ThreadFunc(void *data)
sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
}
- printf("Thread '%d' waiting for signal\n", tid);
+ SDL_Log("Thread '%d' waiting for signal\n", tid);
while (time_for_threads_to_die[tid] != 1) {
; /* do nothing */
}
- printf("Thread '%d' sending signals to subthreads\n", tid);
+ SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
for (i = 0; i < NUMTHREADS; i++) {
flags[i] = 1;
SDL_WaitThread(sub_threads[i], NULL);
}
- printf("Thread '%d' exiting!\n", tid);
+ SDL_Log("Thread '%d' exiting!\n", tid);
return 0;
}
@@ -80,9 +80,12 @@ main(int argc, char *argv[])
SDL_Thread *threads[NUMTHREADS];
int i;
+ /* Enable standard application logging */
+ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
+
/* Load the SDL library */
if (SDL_Init(0) < 0) {
- fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return (1);
}
@@ -94,7 +97,7 @@ main(int argc, char *argv[])
threads[i] = SDL_CreateThread(ThreadFunc, name, (void*) (uintptr_t) i);
if (threads[i] == NULL) {
- fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError());
quit(1);
}
}