File: glfwrm.tex

package info (click to toggle)
glfw 2.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 3,172 kB
  • ctags: 2,055
  • sloc: ansic: 14,940; objc: 934; pascal: 521; sh: 445; makefile: 174
file content (3238 lines) | stat: -rw-r--r-- 114,468 bytes parent folder | download
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
%-------------------------------------------------------------------------
% GLFW Reference Manual
% API Version: 2.7
%-------------------------------------------------------------------------

% Document class
\documentclass[a4paper,11pt,oneside]{report}

% Document title and API version
\newcommand{\glfwdoctype}[1][0]{Reference Manual}
\newcommand{\glfwapiver}[1][0]{2.7}

% Common document settings and macros
\input{glfwdoc.sty}

% PDF specific document settings
\hypersetup{pdftitle={GLFW Reference Manual}}
\hypersetup{pdfauthor={Camilla Berglund}}
\hypersetup{pdfkeywords={GLFW,OpenGL,reference,manual}}


%-------------------------------------------------------------------------
% Document body
%-------------------------------------------------------------------------

\begin{document}

\pagestyle{plain}

% Title page
\glfwmaketitle

% Summary, trademarks and table of contents
\pagenumbering{roman}
\setcounter{page}{1}

%-------------------------------------------------------------------------
% Summary and Trademarks
%-------------------------------------------------------------------------
\chapter*{Summary}

This document is primarily a function reference manual for the \GLFW\ API.
For a description of how to use \GLFW\ you should refer to the
\textit{GLFW Users Guide}.
\vspace{5cm}

\large
Trademarks

\small
OpenGL and IRIX are registered trademarks of Silicon Graphics, Inc.\linebreak
Microsoft and Windows are registered trademarks of Microsoft Corporation.\linebreak
Mac OS is a registered trademark of Apple Computer, Inc.\linebreak
Linux is a registered trademark of Linus Torvalds.\linebreak
FreeBSD is a registered trademark of Wind River Systems, Inc.\linebreak
Solaris is a trademark of Sun Microsystems, Inc.\linebreak
UNIX is a registered trademark of The Open Group.\linebreak
X Window System is a trademark of The Open Group.\linebreak
POSIX is a trademark of IEEE.\linebreak
Truevision, TARGA and TGA are registered trademarks of Truevision, Inc.\linebreak

All other trademarks mentioned in this document are the property of their respective owners.
\normalsize


%-------------------------------------------------------------------------
% Table of contents
%-------------------------------------------------------------------------
\tableofcontents

%-------------------------------------------------------------------------
% List of tables
%-------------------------------------------------------------------------
\listoftables
\pagebreak


% Document chapters starts here...
\pagenumbering{arabic}
\setcounter{page}{1}

\pagestyle{fancy}


%-------------------------------------------------------------------------
% Introduction
%-------------------------------------------------------------------------
\chapter{Introduction}
\thispagestyle{fancy}

\GLFW\ is a portable API (Application Program Interface) that handles
operating system specific tasks related to \OpenGL\ programming. While
\OpenGL\ in general is portable, easy to use and often results in tidy and
compact code, the operating system specific mechanisms that are required
to set up and manage an \OpenGL\ window are quite the opposite. \GLFW\ tries
to remedy this by providing the following functionality:

\begin{itemize}
\item Opening and managing an \OpenGL\ context and its associated window.
\item Keyboard, mouse and joystick input.
\item A high precision timer.
\item Multi-threading support.
\item Support for querying and using \OpenGL\ extensions.
\item Basic Targa image loading support.
\end{itemize}

All this functionality is implemented as a set of easy-to-use functions,
which makes it possible to write an \OpenGL\ application framework in just a
few lines of code. The \GLFW\ API looks and behaves the same on all supported
platforms, making it very simple to port \GLFW\ based \OpenGL\ applications to
a variety of platforms.

Currently supported platforms are:
\begin{itemize}
\item Microsoft Windows\textsuperscript{\textregistered} (32-bit only).
\item Unix\textsuperscript{\textregistered} or Unix-like systems running
resonably a modern version of the X Window
System\texttrademark\footnote{X11.app on Mac OS X is not supported due to its
incomplete implementation of GLXFBConfigs} e.g.
Linux\textsuperscript{\textregistered},
FreeBSD\textsuperscript{\textregistered} and Solaris\texttrademark (32- and
64-bit).
\item Mac OS\textsuperscript{\textregistered} X, using Cocoa\footnote{Joystick
input is not yet supported on Mac OS X.} (32- and 64-bit).
\end{itemize}



%-------------------------------------------------------------------------
% GLFW Operation
%-------------------------------------------------------------------------
\chapter{GLFW Operation Overview}
\thispagestyle{fancy}


%-------------------------------------------------------------------------
\section{The GLFW Window}
\GLFW\ only supports having one window open at a time. The window can be either
a normal desktop window or a fullscreen window. The latter is completely
undecorated, without window borders, and covers the entire monitor. With a
fullscreen window, it is also possible to select which video mode to use.

When a window is opened, an \OpenGL\ rendering context is created and
attached to the entire client area of the window. When the window is closed,
the \OpenGL\ rendering context is detached and destroyed.

Through a window it is possible to receive user input in the form of
keyboard and mouse input. User input is exposed through the \GLFW\ API
primarily via a set of callback functions. Also, \GLFW\ stores most user input
as internal state that can be queried through different \GLFW\ API functions
(for instance it is possible to query the position of the mouse cursor with the
\textbf{glfwGetMousePos} function).

As for user input, it is possible to receive information about window
state changes, such as window resize or close events, through callback
functions. It is also possible to query some kinds of information about the
window information using \GLFW\ API functions.


%-------------------------------------------------------------------------
\section{The GLFW Event Loop}
The \GLFW\ event loop is an open loop, which means that it is up to the
programmer to design the loop. Events are processed by calling specific
\GLFW\ functions, which in turn query the system for new input and window
events and reports these events back to the program through callback
functions.

The programmer decides when to call the event processing functions and
when to abort the event loop.

In pseudo language, a typical event loop might look like this:

\begin{lstlisting}
  repeat until window is closed
  {
    poll events
    draw OpenGL graphics
  }
\end{lstlisting}

There are two ways to handle events in \GLFW :

\begin{itemize}
  \item Block the event loop while waiting for new events.
  \item Poll for new events and continue the loop regardless of whether there
        are any new events or not.
\end{itemize}

The first method is useful for interactive applications that do not
need to refresh the \OpenGL\ display unless the user interacts with the
application through user input. Typical applications are CAD software
and other kinds of editors.

The second method is useful for applications that need to refresh the
\OpenGL\ display constantly, regardless of user input, such as games,
demos, 3D animations, screen savers and so on.


%-------------------------------------------------------------------------
\section{Callback Functions}
Using callback functions can be a good method for receiving up to date
information about window state and user input. When a window has been
opened, it is possible to register custom callback functions that will
be called when certain events occur.

Callback functions are called from any of the event polling functions
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
\textbf{glfwSwapBuffers}.

Callback functions should \emph{only} be used to gather information. Since
the callback functions are called from within the internal \GLFW\ event
polling loops, they should not call any \GLFW\ functions that might
result in considerable \GLFW\ state changes, nor stall the event polling
loop for a lengthy period of time.

In other words, most or all \OpenGL\ rendering should be called from the
main application event loop, not from any of the \GLFW\ callback
functions. Also, the only \GLFW\ functions that may be safely called from
callback functions are the different Get functions (e.g.
\textbf{glfwGetKey}, \textbf{glfwGetTime}, \textbf{glfwGetWindowParam}
etc.).


%-------------------------------------------------------------------------
\section{Threads}
\GLFW\ has functions for creating threads, which means that it is possible
to make multi-threaded applications with \GLFW . The thread that calls
\textbf{glfwInit} becomes the main thread, and it is recommended that all
\GLFW\ and \OpenGL\ functions are called from the main thread. Additional
threads should primarily be used for CPU heavy tasks or for managing
other resources such as file or sound I/O.

It should be noted that the current implementation of \GLFW\ is not thread
safe, so you should never call \GLFW\ functions from different threads.
\footnote{The thread management functions are of course thread safe.}


%-------------------------------------------------------------------------
% Function Reference
%-------------------------------------------------------------------------
\chapter{Function Reference}
\thispagestyle{fancy}

%-------------------------------------------------------------------------
\section{GLFW Initialization and Termination}
Before any other \GLFW\ functions can be used, \GLFW\ must be initialized to
ensure proper functionality, and before a program terminates \GLFW\ should be
terminated in order to free allocated resources, memory, etc.


%-------------------------------------------------------------------------
\subsection{glfwInit}

\textbf{C language syntax}
\begin{lstlisting}
int glfwInit( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
If the function succeeds, GL\_TRUE is returned.\\
If the function fails, GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
The glfwInit function initializes \GLFW. No other \GLFW\ functions may be
called before this function has succeeded.
\end{refdescription}

\begin{refnotes}
This function may take several seconds to complete on some systems, while
on other systems it may take only a fraction of a second to complete.

This function registers a function calling \textbf{glfwTerminate} with the
atexit facility of the C library.

On Mac OS X, this function will change the current directory of the application
to the \textbf{Contents/Resources} subdirectory of the application's bundle, if
present.  For more information on bundles, see the Bundle Programming Guide
provided by Apple.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwTerminate}

\textbf{C language syntax}
\begin{lstlisting}
void glfwTerminate( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function terminates \GLFW. Among other things it closes the window, if
open, and kills any running threads. This function should be called before a
program exits.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwGetVersion}

\textbf{C language syntax}
\begin{lstlisting}
void glfwGetVersion( int *major, int *minor, int *rev )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{major}]\ \\
  Pointer to an integer that will hold the major version number.
\item [\textit{minor}]\ \\
  Pointer to an integer that will hold the minor version number.
\item [\textit{rev}]\ \\
  Pointer to an integer that will hold the revision.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the major and minor version numbers and the revision
for the currently linked \GLFW\ library.
\end{refreturn}

\begin{refdescription}
This function returns the \GLFW\ library version.
\end{refdescription}


%-------------------------------------------------------------------------
\pagebreak
\section{Window Handling}
The primary purpose of \GLFW\ is to provide a simple interface to
\OpenGL\ context creation and window management. \GLFW\ supports one window at
a time, which can be either a normal desktop window or a fullscreen window.


%-------------------------------------------------------------------------
\subsection{glfwOpenWindow}

\textbf{C language syntax}
\begin{lstlisting}
int glfwOpenWindow( int width, int height, int redbits,
    int greenbits, int bluebits, int alphabits, int depthbits,
    int stencilbits, int mode )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{width}]\ \\
  The width of the window. If \textit{width} is zero, it will be
  calculated as ${width=\frac{4}{3}height}$, if \textit{height} is not
  zero. If both \textit{width} and \textit{height} are zero,
  \textit{width} will be set to 640.
\item [\textit{height}]\ \\
  The height of the window. If \textit{height} is zero, it will be
  calculated as ${height=\frac{3}{4}width}$, if \textit{width} is not
  zero. If both \textit{width} and \textit{height} are zero,
  \textit{height} will be set to 480.
\item [\textit{redbits, greenbits, bluebits}]\ \\
  The number of bits to use for each color component of the color buffer
  (0 means default color depth). For instance, setting \textit{redbits=5,
  greenbits=6 and bluebits=5} will create a 16-bit color buffer, if
  possible.
\item [\textit{alphabits}]\ \\
  The number of bits to use for the alpha channel of the color buffer (0 means
  no alpha channel).
\item [\textit{depthbits}]\ \\
  The number of bits to use for the depth buffer (0 means no depth
  buffer).
\item [\textit{stencilbits}]\ \\
  The number of bits to use for the stencil buffer (0 means no stencil
  buffer).
\item [\textit{mode}]\ \\
  Selects which type of \OpenGL\ window to use. \textit{mode} must be
  either GLFW\_WINDOW, which will generate a normal desktop window, or
  GLFW\_FULLSCREEN, which will generate a window which covers the entire
  screen. When GLFW\_FULLSCREEN is selected, the video mode will be
  changed to the resolution that closest matches the \textit{width} and
  \textit{height} parameters.
\end{description}
\end{refparameters}

\begin{refreturn}
If the function succeeds, GL\_TRUE is returned.\\
If the function fails, GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
This function opens a window that best matches the parameters given to the
function. How well the resulting window matches the desired window depends
mostly on the available hardware and \OpenGL\ drivers. In general,
selecting a fullscreen mode has better chances of generating a close match
of buffers and channel sizes than does a normal desktop window, since \GLFW\
can freely select from all the available video modes. A desktop window is
normally restricted to the video mode of the desktop.
\end{refdescription}

\begin{refnotes}
For additional control of window properties, see
\textbf{glfwOpenWindowHint}.

In fullscreen mode the mouse cursor is hidden by default and the
screensaver is prohibited from starting. In windowed mode the mouse
cursor is visible and screensavers are allowed to start. To change the
visibility of the mouse cursor, use \textbf{glfwEnable} or
\textbf{glfwDisable} with the argument GLFW\_MOUSE\_CURSOR.

In order to determine the actual properties of an opened window, use
\textbf{glfwGetWindowParam} and \textbf{glfwGetWindowSize} (or
\textbf{glfwSetWindowSizeCallback}).

On Microsoft Windows, if the executable has an icon resource named
\textbf{GLFW\_ICON}, it will be set as the icon for the window.  If no such
icon is present, the \textbf{IDI\_WINLOGO} icon will be used instead.

On Mac OS X the \GLFW\ window has no icon, but programs using \GLFW\ will use
the application bundle's icon.  For more information on bundles, see the Bundle
Programming Guide provided by Apple.

For information on how the availability of different platform-specific
extensions affect the behavior of this function, see appendix
\ref{chap:compatibility}.
\end{refnotes}


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|l|p{7.0cm}|} \hline \raggedright
\textbf{Name}            & \textbf{Default} & \textbf{Description} \\ \hline
GLFW\_REFRESH\_RATE      & 0                & Vertical monitor refresh rate in Hz (only used for fullscreen windows). Zero means system default.\\ \hline
GLFW\_ACCUM\_RED\_BITS   & 0                & Number of bits for the red channel of the accumulation buffer.\\ \hline
GLFW\_ACCUM\_GREEN\_BITS & 0                & Number of bits for the green channel of the accumulation buffer.\\ \hline
GLFW\_ACCUM\_BLUE\_BITS  & 0                & Number of bits for the blue channel of the accumulation buffer.\\ \hline
GLFW\_ACCUM\_ALPHA\_BITS & 0                & Number of bits for the alpha channel of the accumulation buffer.\\ \hline
GLFW\_AUX\_BUFFERS       & 0                & Number of auxiliary buffers.\\ \hline
GLFW\_STEREO             & GL\_FALSE        & Specify if stereo rendering should be supported (can be GL\_TRUE or GL\_FALSE).\\ \hline
GLFW\_WINDOW\_NO\_RESIZE & GL\_FALSE        & Specify whether the window can be resized by the user (not used for fullscreen windows).\\ \hline
GLFW\_FSAA\_SAMPLES      & 0                & Number of samples to use for the multisampling buffer. Zero disables multisampling.\\ \hline
GLFW\_OPENGL\_VERSION\_MAJOR & 1	        & Major number of the desired minimum \OpenGL\ version.\\ \hline
GLFW\_OPENGL\_VERSION\_MINOR & 1	        & Minor number of the desired minimum \OpenGL\ version.\\ \hline
GLFW\_OPENGL\_FORWARD\_COMPAT & GL\_FALSE   & Specify whether the \OpenGL\ context should be forward-compatible (i.e. disallow legacy functionality).
                                              This should only be used when requesting \OpenGL\ version 3.0 or above.\\ \hline
GLFW\_OPENGL\_DEBUG\_CONTEXT & GL\_FALSE    & Specify whether a debug context should be created.\\ \hline
GLFW\_OPENGL\_PROFILE    & 0                & The \OpenGL\ profile the context should implement, or zero to let the system choose.
                                              Available profiles are GLFW\_OPENGL\_CORE\_PROFILE and GLFW\_OPENGL\_COMPAT\_PROFILE.\\ \hline
\end{tabular}
\end{center}
\caption{Targets for \textbf{glfwOpenWindowHint}}
\label{tab:winhints}
\end{table}


%-------------------------------------------------------------------------
\subsection{glfwOpenWindowHint}

\textbf{C language syntax}
\begin{lstlisting}
void glfwOpenWindowHint( int target, int hint )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{target}]\ \\
  Can be any of the tokens in the table \ref{tab:winhints}.
\item [\textit{hint}]\ \\
  An integer giving the value of the corresponding token (see table
  \ref{tab:winhints}).
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets additional properties for a window that is to be opened.
For a hint to take effect, it must be set \emph{before} calling
\textbf{glfwOpenWindow}.  When \textbf{glfwOpenWindow} is called, regardless of
whether it succeeds, all window hints are reset to their default values.
\end{refdescription}

\begin{refnotes}
All window hints are reset to their default values by each successful call to
\textbf{glfwInit} and by each call to \textbf{glfwOpenWindow}, whether
successful or not.

In order to determine the actual properties of an opened window, use
\textbf{glfwGetWindowParam} (after the window has been opened).

GLFW\_STEREO is a hard constraint. If stereo rendering is requested, but no
stereo rendering capable pixel formats / framebuffer configs are available,
\textbf{glfwOpenWindow} will fail.

The GLFW\_REFRESH\_RATE hint should be used with caution. Most
systems have default values for monitor refresh rates that are optimal
for the specific system. Specifying the refresh rate can override these
settings, which can result in suboptimal operation. The monitor may be
unable to display the resulting video signal, or in the worst case it may
even be damaged!

The GLFW\_WINDOW\_NO\_RESIZE hint applies only to manual resizing by the user.
A window created with this hint enabled can still be resized by the application
by calling \textbf{glfwSetWindowSize}.

The GLFW\_OPENGL\_VERSION\_MAJOR and GLFW\_OPENGL\_VERSION\_MINOR hints specify
the \OpenGL\ version that the created context must be compatible with,
\emph{not} the exact version to use.  It is therefore perfectly safe to use the
default of version 1.1 for legacy code and you will still get
backwards-compatible contexts of version 3.0 and above when available.

To make the behavior of the above version hints consistent across both modern
and legacy drivers, \textbf{glfwOpenWindow} will fail if the modern creation
mechanism (as specified in \textbf{WGL\_ARB\_create\_context}
and \textbf{GLX\_ARB\_create\_context}) is unavailable \emph{and} the created
context is of a version lower than the one that was requested.

At the time of release, the exact meaning of what a "debug context" is (as
created using the GLFW\_OPENGL\_DEBUG\_CONTEXT hint) has yet to be defined by
the Khronos ARB WG.

For information on how the availability of different extensions affect the
behavior of this function, see appendix \ref{chap:compatibility}.

For full details on the workings of the \OpenGL\ version, forward-compatibility
and debug hints, see the specifications for \textbf{WGL\_ARB\_create\_context}
and \textbf{GLX\_ARB\_create\_context}, respectively.  The relevant \GLFW\
hints map very closely to their platform-specific counterparts.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwCloseWindow}

\textbf{C language syntax}
\begin{lstlisting}
void glfwCloseWindow( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function closes an opened window and destroys the associated \OpenGL\
context.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwSetWindowCloseCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called when a user requests
  that the window should be closed, typically by clicking the window close
  icon (e.g. the cross in the upper right corner of a window under
  Microsoft Windows), and on Mac OS X also when selecting \textbf{Quit} from
  the application menu. The function should have the following C language
  prototype:

  \texttt{int GLFWCALL functionname( void );}

  Where \textit{functionname} is the name of the callback function. The
  return value of the callback function indicates wether or not the window
  close action should continue. If the function returns GL\_TRUE, the
  window will be closed. If the function returns GL\_FALSE, the window
  will not be closed.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for window close events.

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Window close events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.

The \OpenGL\ context is still valid when this function is called.

Note that the window close callback function is not called when
\textbf{glfwCloseWindow} is called, but only when the close request
comes from the window manager.

Do \emph{not} call \textbf{glfwCloseWindow} from a window close
callback function. Close the window by returning GL\_TRUE from the
function.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetWindowTitle}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetWindowTitle( const char *title )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{title}]\ \\
  Pointer to a  null terminated ISO~8859-1 (8-bit Latin~1) string that
  holds the title of the window.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function changes the title of the opened window.
\end{refdescription}

\begin{refnotes}
The title property of a window is often used in situations other than for
the window title, such as the title of an application icon when it is in
iconified state.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetWindowSize}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetWindowSize( int width, int height )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{width}]\ \\
  Width of the window.
\item [\textit{height}]\ \\
  Height of the window.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function changes the size of an opened window. The \textit{width} and
\textit{height} parameters denote the size of the client area of the
window (i.e. excluding any window borders and decorations).

If the window is in fullscreen mode, the video mode will be changed to a
resolution that closest matches the width and height parameters (the
number of color bits will not be changed).
\end{refdescription}

\begin{refnotes}
This function has no effect if the window is iconified.

The \OpenGL\ context is guaranteed to be preserved after calling
\textbf{glfwSetWindowSize}, even if the video mode is changed.

This function is not affected by the value of the GLFW\_WINDOW\_NO\_RESIZE
hint.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetWindowPos}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetWindowPos( int x, int y )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{x}]\ \\
  Horizontal position of the window, relative to the upper left corner
  of the desktop.
\item [\textit{y}]\ \\
  Vertical position of the window, relative to the upper left corner of
  the desktop.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function changes the position of an opened window. It does not have
any effect on a fullscreen window.
\end{refdescription}

\begin{refnotes}
This function has no effect if the window is iconified.

The behaviour of this function on multi-monitor systems is ill-defined.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetWindowSize}

\textbf{C language syntax}
\begin{lstlisting}
void glfwGetWindowSize( int *width, int *height )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{width}]\ \\
  Pointer to an integer that will hold the width of the window.
\item [\textit{height}]\ \\
  Pointer to an integer that will hold the height of the window.
\end{description}
\end{refparameters}

\begin{refreturn}
The current width and height of the opened window is returned in the
\textit{width} and \textit{height} parameters, respectively.
\end{refreturn}

\begin{refdescription}
This function is used for determining the size of an opened window.
The returned values are dimensions of the client area of the window
(i.e. excluding any window borders and decorations).
\end{refdescription}

\begin{refnotes}
Even if the size of a fullscreen window does not change once the window
has been opened, it does not necessarily have to be the same as the size
that was requested using \textbf{glfwOpenWindow}. Therefor it is wise to
use this function to determine the true size of the window once it has
been opened.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetWindowSizeCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called every time the
  window size changes. The function should have the following C language
  prototype:

  \texttt{void GLFWCALL functionname( int width, int height );}

  Where \textit{functionname} is the name of the callback function, and
  \textit{width} and \textit{height} are the dimensions of the window
  client area.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for window size change events.

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Window size changes are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.

When a callback function is set, it will be called with the current window
size before this function returns.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwIconifyWindow}

\textbf{C language syntax}
\begin{lstlisting}
void glfwIconifyWindow( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
Iconify a window. If the window is in fullscreen mode, then the desktop
video mode will be restored.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwRestoreWindow}

\textbf{C language syntax}
\begin{lstlisting}
void glfwRestoreWindow( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
Restore an iconified window. If the window that is restored is in
fullscreen mode, then the fullscreen video mode will be restored.
\end{refdescription}


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|p{9.5cm}|} \hline \raggedright
\textbf{Name}            & \textbf{Description} \\ \hline
GLFW\_OPENED             & GL\_TRUE if window is opened, else GL\_FALSE.\\ \hline
GLFW\_ACTIVE             & GL\_TRUE if window has focus, else GL\_FALSE.\\ \hline
GLFW\_ICONIFIED          & GL\_TRUE if window is iconified, else GL\_FALSE.\\ \hline
GLFW\_ACCELERATED        & GL\_TRUE if window is hardware accelerated, else GL\_FALSE.\\ \hline
GLFW\_RED\_BITS          & Number of bits for the red color component.\\ \hline
GLFW\_GREEN\_BITS        & Number of bits for the green color component.\\ \hline
GLFW\_BLUE\_BITS         & Number of bits for the blue color component.\\ \hline
GLFW\_ALPHA\_BITS        & Number of bits for the alpha buffer.\\ \hline
GLFW\_DEPTH\_BITS        & Number of bits for the depth buffer.\\ \hline
GLFW\_STENCIL\_BITS      & Number of bits for the stencil buffer.\\ \hline
GLFW\_REFRESH\_RATE      & Vertical monitor refresh rate in Hz. Zero indicates an unknown or a default refresh rate.\\ \hline
GLFW\_ACCUM\_RED\_BITS   & Number of bits for the red channel of the accumulation buffer.\\ \hline
GLFW\_ACCUM\_GREEN\_BITS & Number of bits for the green channel of the accumulation buffer.\\ \hline
GLFW\_ACCUM\_BLUE\_BITS  & Number of bits for the blue channel of the accumulation buffer.\\ \hline
GLFW\_ACCUM\_ALPHA\_BITS & Number of bits for the alpha channel of the accumulation buffer.\\ \hline
GLFW\_AUX\_BUFFERS       & Number of auxiliary buffers.\\ \hline
GLFW\_STEREO             & GL\_TRUE if stereo rendering is supported, else GL\_FALSE.\\ \hline
GLFW\_WINDOW\_NO\_RESIZE & GL\_TRUE if the window cannot be resized by the user, else GL\_FALSE.\\ \hline
GLFW\_FSAA\_SAMPLES      & Number of multisampling buffer samples. Zero indicated multisampling is disabled.\\ \hline
GLFW\_OPENGL\_VERSION\_MAJOR & Major number of the actual version of the context.\\ \hline
GLFW\_OPENGL\_VERSION\_MINOR & Minor number of the actual version of the context.\\ \hline
GLFW\_OPENGL\_FORWARD\_COMPAT & GL\_TRUE if the context is forward-compatible, else GL\_FALSE.\\ \hline
GLFW\_OPENGL\_DEBUG\_CONTEXT & GL\_TRUE if the context is a debug context.\\ \hline
GLFW\_OPENGL\_PROFILE    & The profile implemented by the context, or zero.\\ \hline
\end{tabular}
\end{center}
\caption{Window parameters for \textbf{glfwGetWindowParam}}
\label{tab:winparams}
\end{table}


%-------------------------------------------------------------------------
\subsection{glfwGetWindowParam}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetWindowParam( int param )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{param}]\ \\
  A token selecting which parameter the function should return (see
  table \ref{tab:winparams}).
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the value the window parameter corresponding to the token
\textit{param}.  Table \ref{tab:winparams} lists the available tokens.
\end{refreturn}

\begin{refdescription}
This function is used for acquiring various properties of an opened window.
\end{refdescription}

\begin{refnotes}
GLFW\_ACCELERATED is only supported under Windows. Other systems will
always return GL\_TRUE. Under Windows, GLFW\_ACCELERATED means that the
\OpenGL\ renderer is a 3rd party renderer, rather than the fallback
Microsoft software \OpenGL\ renderer. In other words, it is not a real
guarantee that the \OpenGL\ renderer is actually hardware accelerated.

GLFW\_OPENGL\_VERSION\_MAJOR and GLFW\_OPENGL\_VERSION\_MINOR always return the
same values as those returned by \textbf{glfwGetGLVersion}.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSwapBuffers}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSwapBuffers( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function swaps the back and front color buffers of the window. If
GLFW\_AUTO\_POLL\_EVENTS is enabled (which is the default),
\textbf{glfwPollEvents} is called after swapping the front and back
buffers.
\end{refdescription}

\begin{refnotes}
In previous versions of \GLFW , \textbf{glfwPollEvents} was called
\emph{before} buffer swap.  This was changed in order to decrease input
lag but may affect code that relied on the former behavior.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSwapInterval}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSwapInterval( int interval )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{interval}]\ \\
  Minimum number of monitor vertical retraces between each buffer swap
  performed by \textbf{glfwSwapBuffers}. If \textit{interval} is zero,
  buffer swaps will not be synchronized to the vertical refresh of the
  monitor (also known as 'VSync off').
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function selects the minimum number of monitor vertical retraces that
should occur between two buffer swaps. If the selected swap interval is
one, the rate of buffer swaps will never be higher than the vertical
refresh rate of the monitor. If the selected swap interval is zero, the
rate of buffer swaps is only limited by the speed of the software and
the hardware.
\end{refdescription}

\begin{refnotes}
This function will only have an effect on hardware and drivers that support
user selection of the swap interval.  ATI drivers in particular have been known
to ignore this setting.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetWindowRefreshCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called when the window client
  area needs to be refreshed. The function should have the following C
  language prototype:

  \texttt{void GLFWCALL functionname( void );}

  Where \textit{functionname} is the name of the callback function.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for window refresh events, which occurs when
any part of the window client area has been damaged, and needs to be repainted
(for instance, if a part of the window that was previously occluded by another
window has become visible).

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Window refresh events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.

Modern windowing systems using hardware compositing, such as Aqua, Aero and
Compiz, very rarely need to refresh the contents of windows, so the specified
callback will very rarely be called on such systems.
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{Video Modes}
Since \GLFW\ supports video mode changes when using a fullscreen window,
it also provides functionality for querying which video modes are
supported on a system.


%-------------------------------------------------------------------------
\subsection{glfwGetVideoModes}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{list}]\ \\
  A vector of \textit{GLFWvidmode} structures, which will be filled out
  by the function.
\item [\textit{maxcount}]\ \\
  Maximum number of video modes that \textit{list} vector can hold.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the number of detected video modes (this number
will never exceed \textit{maxcount}). The \textit{list} vector is
filled out with the video modes that are supported by the system.
\end{refreturn}

\begin{refdescription}
This function returns a list of supported video modes. Each video mode is
represented by a \textit{GLFWvidmode} structure, which has the following
definition:

\begin{lstlisting}
typedef struct {
    int Width, Height; // Video resolution
    int RedBits;       // Number of red bits
    int GreenBits;     // Number of green bits
    int BlueBits;      // Number of blue bits
} GLFWvidmode;
\end{lstlisting}
\end{refdescription}

\begin{refnotes}
The returned list is sorted, first by color depth ($RedBits + GreenBits +
BlueBits$), and then by resolution ($Width \times Height$), with the
lowest resolution, fewest bits per pixel mode first.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetDesktopMode}

\textbf{C language syntax}
\begin{lstlisting}
void glfwGetDesktopMode( GLFWvidmode *mode )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{mode}]\ \\
  Pointer to a \textit{GLFWvidmode} structure, which will be filled out
  by the function.
\end{description}
\end{refparameters}

\begin{refreturn}
The \textit{GLFWvidmode} structure pointed to by \textit{mode} is filled
out with the desktop video mode.
\end{refreturn}

\begin{refdescription}
This function returns the desktop video mode in a \textit{GLFWvidmode}
structure. See \textbf{glfwGetVideoModes} for a definition of the
\textit{GLFWvidmode} structure.
\end{refdescription}

\begin{refnotes}
The color depth of the desktop display is always reported as the number
of bits for each individual color component (red, green and blue), even
if the desktop is not using an RGB or RGBA color format. For instance, an
indexed 256 color display may report \textit{RedBits} = 3,
\textit{GreenBits} = 3 and \textit{BlueBits} = 2, which adds up to 8 bits
in total.

The desktop video mode is the video mode used by the desktop at the time
the \GLFW\ window was opened, \textit{not} the current video mode (which
may differ from the desktop video mode if the \GLFW\ window is a
fullscreen window).
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{Input Handling}
\GLFW\ supports three channels of user input: keyboard input, mouse input
and joystick input.

Keyboard and mouse input can be treated either as events, using callback
functions, or as state, using functions for polling specific keyboard and
mouse states. Regardless of which method is used, all keyboard and mouse
input is collected using window event polling.

Joystick input is asynchronous to the keyboard and mouse input, and does
not require event polling for keeping up to date joystick information.
Also, joystick input is independent of any window, so a window does not
have to be opened for joystick input to be used.


%-------------------------------------------------------------------------
\subsection{glfwPollEvents}

\textbf{C language syntax}
\begin{lstlisting}
void glfwPollEvents( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function is used for polling for events, such as user input and
window resize events. Upon calling this function, all window states,
keyboard states and mouse states are updated. If any related callback
functions are registered, these are called during the call to
\textbf{glfwPollEvents}.
\end{refdescription}

\begin{refnotes}
\textbf{glfwPollEvents} is called implicitly from \textbf{glfwSwapBuffers}
if GLFW\_AUTO\_POLL\_EVENTS is enabled (as it is by default). Thus, if
\textbf{glfwSwapBuffers} is called frequently, which is normally the case,
there is no need to call \textbf{glfwPollEvents}.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwWaitEvents}

\textbf{C language syntax}
\begin{lstlisting}
void glfwWaitEvents( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function is used for waiting for events, such as user input and
window resize events. Upon calling this function, the calling thread will
be put to sleep until any event appears in the event queue. When events
are available, they will be processed just as they are processed by
\textbf{glfwPollEvents}.

If there are any events in the queue when the function is called, the
function will behave exactly like \textbf{glfwPollEvents} (i.e. process
all messages and then return, without blocking the calling thread).
\end{refdescription}

\begin{refnotes}
It is guaranteed that \textbf{glfwWaitEvents} will wake up on any event that
can be processed by \textbf{glfwPollEvents}. However, \GLFW\ receives many
events that are only processed internally and the function may behave
differently on different systems. Do not make any assumptions about when or why
\textbf{glfwWaitEvents} will return.
\end{refnotes}


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|l|} \hline \raggedright
\textbf{Name}             & \textbf{Description} \\ \hline
GLFW\_KEY\_SPACE          & Space\\ \hline
GLFW\_KEY\_ESC            & Escape\\ \hline
GLFW\_KEY\_F\textit{n}    & Function key \textit{n} (\textit{n} can be in the range 1..25)\\ \hline
GLFW\_KEY\_UP             & Cursor up\\ \hline
GLFW\_KEY\_DOWN           & Cursor down\\ \hline
GLFW\_KEY\_LEFT           & Cursor left\\ \hline
GLFW\_KEY\_RIGHT          & Cursor right\\ \hline
GLFW\_KEY\_LSHIFT         & Left shift key\\ \hline
GLFW\_KEY\_RSHIFT         & Right shift key\\ \hline
GLFW\_KEY\_LCTRL          & Left control key\\ \hline
GLFW\_KEY\_RCTRL          & Right control key\\ \hline
GLFW\_KEY\_LALT           & Left alternate function key\\ \hline
GLFW\_KEY\_RALT           & Right alternate function key\\ \hline
GLFW\_KEY\_LSUPER         & Left super key, WinKey, or command key\\ \hline
GLFW\_KEY\_RSUPER         & Right super key, WinKey, or command key\\ \hline
GLFW\_KEY\_TAB            & Tabulator\\ \hline
GLFW\_KEY\_ENTER          & Enter\\ \hline
GLFW\_KEY\_BACKSPACE      & Backspace\\ \hline
GLFW\_KEY\_INSERT         & Insert\\ \hline
GLFW\_KEY\_DEL            & Delete\\ \hline
GLFW\_KEY\_PAGEUP         & Page up\\ \hline
GLFW\_KEY\_PAGEDOWN       & Page down\\ \hline
GLFW\_KEY\_HOME           & Home\\ \hline
GLFW\_KEY\_END            & End\\ \hline
GLFW\_KEY\_KP\_\textit{n} & Keypad numeric key \textit{n} (\textit{n} can be in the range 0..9)\\ \hline
GLFW\_KEY\_KP\_DIVIDE     & Keypad divide ($\div$)\\ \hline
GLFW\_KEY\_KP\_MULTIPLY   & Keypad multiply ($\times$)\\ \hline
GLFW\_KEY\_KP\_SUBTRACT   & Keypad subtract ($-$)\\ \hline
GLFW\_KEY\_KP\_ADD        & Keypad add ($+$)\\ \hline
GLFW\_KEY\_KP\_DECIMAL    & Keypad decimal (. or ,)\\ \hline
GLFW\_KEY\_KP\_EQUAL      & Keypad equal (=)\\ \hline
GLFW\_KEY\_KP\_ENTER      & Keypad enter\\ \hline
GLFW\_KEY\_KP\_NUM\_LOCK  & Keypad num lock\\ \hline
GLFW\_KEY\_CAPS\_LOCK     & Caps lock\\ \hline
GLFW\_KEY\_SCROLL\_LOCK   & Scroll lock\\ \hline
GLFW\_KEY\_PAUSE          & Pause key\\ \hline
GLFW\_KEY\_MENU           & Menu key\\ \hline
\end{tabular}
\end{center}
\caption{Special key identifiers}
\label{tab:keys}
\end{table}


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|l|} \hline \raggedright
\textbf{Name}               & \textbf{Description} \\ \hline
GLFW\_MOUSE\_BUTTON\_LEFT   & Left mouse button (button 1) \\ \hline
GLFW\_MOUSE\_BUTTON\_RIGHT  & Right mouse button (button 2) \\ \hline
GLFW\_MOUSE\_BUTTON\_MIDDLE & Middle mouse button (button 3) \\ \hline
GLFW\_MOUSE\_BUTTON\_\textit{n} & Mouse button \textit{n} (\textit{n} can be in the range 1..8)\\ \hline
\end{tabular}
\end{center}
\caption{Valid mouse button identifiers}
\label{tab:mousebuttons}
\end{table}


%-------------------------------------------------------------------------
\subsection{glfwGetKey}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetKey( int key )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{key}]\ \\
  A keyboard key identifier, which can be either an uppercase printable
  ISO~8859-1 (Latin~1) character (e.g. 'A', '3' or '.'), or a special key
  identifier. Table \ref{tab:keys} lists valid special key identifiers.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GLFW\_PRESS if the key is held down, or GLFW\_RELEASE
if the key is not held down.
\end{refreturn}

\begin{refdescription}
This function queries the current state of a specific keyboard key. The
physical location of each key depends on the system keyboard layout
setting.
\end{refdescription}

\begin{refnotes}
The constant GLFW\_KEY\_SPACE is equal to 32, which is the ISO~8859-1 code
for space.  This is the only named \GLFW\ key identifier with a value in the
ISO~8859-1 range.

Not all key codes are supported on all systems. Also, while some keys are
available on some keyboard layouts, they may not be available on other
keyboard layouts.

For systems that do not distinguish between left and right versions of
modifier keys (shift, alt and control), the left version is used (e.g.
GLFW\_KEY\_LSHIFT).

A window must be opened for the function to have any effect, and
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) must be called before any keyboard
events are recorded and reported by \textbf{glfwGetKey}.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetMouseButton}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetMouseButton( int button )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{button}]\ \\
  A mouse button identifier, which can be one of the mouse button
  identifiers listed in table \ref{tab:mousebuttons}.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GLFW\_PRESS if the mouse button is held down, or
GLFW\_RELEASE if the mouse button is not held down.
\end{refreturn}

\begin{refdescription}
This function queries the current state of a specific mouse button.
\end{refdescription}

\begin{refnotes}
A window must be opened for the function to have any effect, and
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) must be called before any mouse button
events are recorded and reported by \textbf{glfwGetMouseButton}.

GLFW\_MOUSE\_BUTTON\_LEFT is equal to GLFW\_MOUSE\_BUTTON\_1.
GLFW\_MOUSE\_BUTTON\_RIGHT is equal to GLFW\_MOUSE\_BUTTON\_2.
GLFW\_MOUSE\_BUTTON\_MIDDLE is equal to GLFW\_MOUSE\_BUTTON\_3.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetMousePos}

\textbf{C language syntax}
\begin{lstlisting}
void glfwGetMousePos( int *xpos, int *ypos )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{xpos}]\ \\
  Pointer to an integer that will be set to the horizontal position of the
  mouse cursor.
\item [\textit{ypos}]\ \\
  Pointer to an integer that will be set to the vertical position of the mouse cursor.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the current mouse cursor position in \textit{xpos} and
\textit{ypos}.
\end{refreturn}

\begin{refdescription}
This function returns the current mouse position. If the cursor is not
hidden, the mouse position is the cursor position, relative to the upper
left corner of the window and with the Y-axis down.  If the cursor is hidden,
the mouse position is a virtual absolute position, not limited to any
boundaries except to those implied by the maximum number that can be
represented by a signed integer.
\end{refdescription}

\begin{refnotes}
A window must be opened for the function to have any effect, and
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) must be called before any mouse
movements are recorded and reported by \textbf{glfwGetMousePos}.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetMousePos}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetMousePos( int xpos, int ypos )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{xpos}]\ \\
  Horizontal position of the mouse.
\item [\textit{ypos}]\ \\
  Vertical position of the mouse.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function changes the position of the mouse. If the cursor is visible (not
disabled), the cursor will be moved to the specified position, relative to the
upper left corner of the window client area and with the Y-axis down.  If the
cursor is hidden (disabled), only the mouse position that is reported by \GLFW\
is changed.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwGetMouseWheel}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetMouseWheel( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
The function returns the current mouse wheel position.
\end{refreturn}

\begin{refdescription}
This function returns the current mouse wheel position. The mouse wheel can
be thought of as a third mouse axis, which is available as a separate
wheel or up/down stick on some mice.
\end{refdescription}

\begin{refnotes}
A window must be opened for the function to have any effect, and
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) must be called before any mouse wheel
movements are recorded and reported by \textbf{glfwGetMouseWheel}.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetMouseWheel}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetMouseWheel( int pos )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{pos}]\ \\
  Position of the mouse wheel.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function changes the position of the mouse wheel.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwSetKeyCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetKeyCallback( GLFWkeyfun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called every time a key is
  pressed or released. The function should have the following C language
  prototype:

  \texttt{void GLFWCALL functionname( int key, int action );}

  Where \textit{functionname} is the name of the callback function,
  \textit{key} is a key identifier, which is an uppercase printable
  ISO~8859-1 character or a special key identifier (see  table
  \ref{tab:keys}), and \textit{action} is either GLFW\_PRESS or
  GLFW\_RELEASE.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for keyboard key events.  The callback function
is called every time the state of a single key is changed (from released to
pressed or vice versa). The reported keys are unaffected by any modifiers (such
as shift or alt) and each modifier is reported as a separate key.

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Keyboard key events are not intended for text input and many languages
will not be able to be input using it.  Use Unicode character events for
text input instead.

Keyboard events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetCharCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetCharCallback( GLFWcharfun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called every time a
  printable character is generated by the keyboard. The function should
  have the following C language prototype:

  \texttt{void GLFWCALL functionname( int character, int action );}

  Where \textit{functionname} is the name of the callback function,
  \textit{character} is a Unicode (ISO~10646) character, and
  \textit{action} is either GLFW\_PRESS or GLFW\_RELEASE.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for keyboard character events.  The callback
function is called every time a key that results in a printable Unicode
character is pressed or released.  Characters are affected by modifiers (such
as shift or alt).

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Character events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.

Control characters such as tab and carriage return are not reported to
the character callback function, since they are not part of the Unicode
character set. Use the key callback function for such events (see
\textbf{glfwSetKeyCallback}).

The Unicode character set supports character codes above 255, so never
cast a Unicode character to an eight bit data type (e.g. the C language
'char' type) without first checking that the character code is less than
256. Also note that Unicode character codes 0 to 255 are equal to
ISO~8859-1 (Latin~1).
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetMouseButtonCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called every time a mouse
  button is pressed or released. The function should have the following C
  language prototype:

  \texttt{void GLFWCALL functionname( int button, int action );}

  Where \textit{functionname} is the name of the callback function,
  \textit{button} is a mouse button identifier (see table
  \ref{tab:mousebuttons} on page \pageref{tab:mousebuttons}), and
  \textit{action} is either GLFW\_PRESS or GLFW\_RELEASE.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for mouse button events.

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Mouse button events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.

GLFW\_MOUSE\_BUTTON\_LEFT is equal to GLFW\_MOUSE\_BUTTON\_1.
GLFW\_MOUSE\_BUTTON\_RIGHT is equal to GLFW\_MOUSE\_BUTTON\_2.
GLFW\_MOUSE\_BUTTON\_MIDDLE is equal to GLFW\_MOUSE\_BUTTON\_3.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetMousePosCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called every time the mouse
  is moved. The function should have the following C language prototype:

  \texttt{void GLFWCALL functionname( int x, int y );}

  Where \textit{functionname} is the name of the callback function, and
  \textit{x} and \textit{y} are the mouse coordinates (see
  \textbf{glfwGetMousePos} for more information on mouse coordinates).

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for mouse motion events.

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Mouse motion events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetMouseWheelCallback}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cbfun}]\ \\
  Pointer to a callback function that will be called every time the mouse
  wheel is moved. The function should have the following C language
  prototype:

  \texttt{void GLFWCALL functionname( int pos );}

  Where \textit{functionname} is the name of the callback function, and
  \textit{pos} is the mouse wheel position.

  If \textit{cbfun} is NULL, any previously set callback function
  will be unset.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the callback for mouse wheel events.

A window has to be opened for this function to have any effect.
\end{refdescription}

\begin{refnotes}
Mouse wheel events are recorded continuously, but only reported when
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled) is called.
\end{refnotes}


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|l|}\hline \raggedright
\textbf{Name} & \textbf{Return value}\\ \hline
GLFW\_PRESENT & GL\_TRUE if the joystick is connected, else GL\_FALSE.\\ \hline
GLFW\_AXES    & Number of axes supported by the joystick.\\ \hline
GLFW\_BUTTONS & Number of buttons supported by the joystick.\\ \hline
\end{tabular}
\end{center}
\caption{Joystick parameters for \textbf{glfwGetJoystickParam}}
\label{tab:joyparams}
\end{table}


%-------------------------------------------------------------------------
\subsection{glfwGetJoystickParam}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetJoystickParam( int joy, int param )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{joy}]\ \\
  A joystick identifier, which should be GLFW\_JOYSTICK\_\textit{n}, where
  \textit{n} is in the range 1 to 16.
\item [\textit{param}]\ \\
  A token selecting which parameter the function should return (see table
  \ref{tab:joyparams}).
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns different parameters depending on the value of
\textit{param}. Table \ref{tab:joyparams} lists valid \textit{param}
values, and their corresponding return values.
\end{refreturn}

\begin{refdescription}
This function is used for acquiring various properties of a joystick.
\end{refdescription}

\begin{refnotes}
The joystick information is updated every time the function is called.

No window has to be opened for joystick information to be available.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetJoystickPos}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetJoystickPos( int joy, float *pos, int numaxes )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{joy}]\ \\
  A joystick identifier, which should be GLFW\_JOYSTICK\_\textit{n}, where
  \textit{n} is in the range 1 to 16.
\item [\textit{pos}]\ \\
  An array that will hold the positional values for all requested axes.
\item [\textit{numaxes}]\ \\
  Specifies how many axes should be returned.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the number of actually returned axes. This is the
minimum of \textit{numaxes} and the number of axes supported by the
joystick. If the joystick is not supported or connected, the function will
return 0 (zero).
\end{refreturn}

\begin{refdescription}
This function queries the current position of one or more axes of a
joystick. The positional values are returned in an array, where the first
element represents the first axis of the joystick (normally the X axis).
Each position is in the range -1.0 to 1.0. Where applicable, the positive
direction of an axis is right, forward or up, and the negative direction
is left, back or down.

If \textit{numaxes} exceeds the number of axes supported by the joystick,
or if the joystick is not available, the unused elements in the
\textit{pos} array will be set to 0.0 (zero).
\end{refdescription}

\begin{refnotes}
The joystick state is updated every time the function is called, so there
is no need to call \textbf{glfwPollEvents} or \textbf{glfwWaitEvents} for
joystick state to be updated.

Use \textbf{glfwGetJoystickParam} to retrieve joystick capabilities, such
as joystick availability and number of supported axes.

No window has to be opened for joystick input to be available.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetJoystickButtons}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetJoystickButtons( int joy, unsigned char *buttons,
                            int numbuttons )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{joy}]\ \\
  A joystick identifier, which should be GLFW\_JOYSTICK\_\textit{n}, where
  \textit{n} is in the range 1 to 16.
\item [\textit{buttons}]\ \\
  An array that will hold the button states for all requested buttons.
\item [\textit{numbuttons}]\ \\
  Specifies how many buttons should be returned.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the number of actually returned buttons. This is the
minimum of \textit{numbuttons} and the number of buttons supported by the
joystick. If the joystick is not supported or connected, the function will
return 0 (zero).
\end{refreturn}

\begin{refdescription}
This function queries the current state of one or more buttons of a
joystick. The button states are returned in an array, where the first
element represents the first button of the joystick. Each state can be
either GLFW\_PRESS or GLFW\_RELEASE.

If \textit{numbuttons} exceeds the number of buttons supported by the
joystick, or if the joystick is not available, the unused elements in the
\textit{buttons} array will be set to GLFW\_RELEASE.
\end{refdescription}

\begin{refnotes}
The joystick state is updated every time the function is called, so there
is no need to call \textbf{glfwPollEvents} or \textbf{glfwWaitEvents} for
joystick state to be updated.

Use \textbf{glfwGetJoystickParam} to retrieve joystick capabilities, such
as joystick availability and number of supported buttons.

No window has to be opened for joystick input to be available.
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{Timing}

%-------------------------------------------------------------------------
\subsection{glfwGetTime}

\textbf{C language syntax}
\begin{lstlisting}
double glfwGetTime( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
The function returns the value of the high precision timer. The time is
measured in seconds, and is returned as a double precision floating point
value.
\end{refreturn}

\begin{refdescription}
This function returns the state of a high precision timer. Unless the timer
has been set by the \textbf{glfwSetTime} function, the time is measured as
the number of seconds that have passed since \textbf{glfwInit} was called.
\end{refdescription}

\begin{refnotes}
The resolution of the timer depends on which system the program is running
on.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSetTime}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSetTime( double time )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{time}]\ \\
  Time (in seconds) that the timer should be set to.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function sets the current time of the high precision timer to the
specified time. Subsequent calls to \textbf{glfwGetTime} will be relative
to this time. The time is given in seconds.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwSleep}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSleep( double time )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{time}]\ \\
  Time, in seconds, to sleep.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function puts the calling thread to sleep for the requested period of
time. Only the calling thread is put to sleep. Other threads within the
same process can still execute.
\end{refdescription}

\begin{refnotes}
There is usually a system dependent minimum time for which it is possible
to sleep. This time is generally in the range 1~$ms$ to 20~$ms$, depending
on thread sheduling time slot intervals etc. Using a shorter time as a
parameter to \textbf{glfwSleep} can give one of two results: either the
thread will sleep for the minimum possible sleep time, or the thread will
not sleep at all (\textbf{glfwSleep} returns immediately). The latter
should only happen when very short sleep times are specified, if at all.
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{Image and Texture Loading}
In order to aid loading of image data into textures, \GLFW\ has basic support
for loading images from files and memory buffers.


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|p{9.0cm}|} \hline \raggedright
\textbf{Name}          & \textbf{Description}\\ \hline
GLFW\_NO\_RESCALE\_BIT & Do not rescale image to closest $2^m\times2^n$ resolution\\ \hline
GLFW\_ORIGIN\_UL\_BIT  & Specifies that the origin of the \textit{loaded} image should be in the upper left corner (default is the lower left corner)\\ \hline
GLFW\_ALPHA\_MAP\_BIT  & Treat single component images as alpha maps rather than luminance maps\\ \hline
\end{tabular}
\end{center}
\caption{Flags for functions loading image data into textures}
\label{tab:rdimgflags}
\end{table}


%-------------------------------------------------------------------------
\subsection{glfwReadImage}

\textbf{C language syntax}
\begin{lstlisting}
int glfwReadImage( const char *name, GLFWimage *img, int flags )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{name}]\ \\
  A null terminated ISO~8859-1 string holding the name of the file that
  should be read.
\item [\textit{img}]\ \\
  Pointer to a GLFWimage struct, which will hold the information about
  the loaded image (if the read was successful).
\item [\textit{flags}]\ \\
  Flags for controlling the image reading process. Valid flags are listed
  in table \ref{tab:rdimgflags}
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the image was loaded successfully.
Otherwise GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
This function reads an image from the file specified by the parameter
\textit{name} and returns the image information and data in a GLFWimage
structure, which has the following definition:

\begin{lstlisting}
typedef struct {
    int Width, Height;    // Image dimensions
    int Format;           // OpenGL pixel format
    int BytesPerPixel;    // Number of bytes per pixel
    unsigned char *Data;  // Pointer to pixel data
} GLFWimage;
\end{lstlisting}

\textit{Width} and \textit{Height} give the dimensions of the image.
\textit{Format} specifies an \OpenGL\ pixel format, which can be
GL\_LUMINANCE or GL\_ALPHA (for gray scale images), GL\_RGB or GL\_RGBA.
\textit{BytesPerPixel} specifies the number of bytes per pixel.
\textit{Data} is a pointer to the actual pixel data.

By default the read image is rescaled to the nearest larger $2^m\times2^n$
resolution using bilinear interpolation, if necessary, which is useful if
the image is to be used as an \OpenGL\ texture. This behavior can be
disabled by setting the GLFW\_NO\_RESCALE\_BIT flag.

Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the first pixel in
\textit{img->Data} is the lower left corner of the image. If the flag
GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
corner.

For single component images (i.e. gray scale), \textit{Format} is set
to GL\_ALPHA if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
\textit{Format} is set to GL\_LUMINANCE.
\end{refdescription}

\begin{refnotes}
\textbf{glfwReadImage} supports the Truevision Targa version 1 file format
(.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted
(24/32-bit color), 24-bit true color and 32-bit true color + alpha.

Paletted images are translated into true color or true color + alpha pixel
formats.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwReadMemoryImage}

\textbf{C language syntax}
\begin{lstlisting}
int glfwReadMemoryImage( const void *data, long size, GLFWimage *img, int flags )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{data}]\ \\
  The memory buffer holding the contents of the file that should be read.
\item [\textit{size}]\ \\
  The size, in bytes, of the memory buffer.
\item [\textit{img}]\ \\
  Pointer to a GLFWimage struct, which will hold the information about
  the loaded image (if the read was successful).
\item [\textit{flags}]\ \\
  Flags for controlling the image reading process. Valid flags are listed
  in table \ref{tab:rdimgflags}
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the image was loaded successfully.
Otherwise GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
This function reads an image file from the memory buffer specified by the
parameter \textit{data} and returns the image information and data in a
GLFWimage structure.  For more information on the \GLFW\ image struct, see
\textbf{glfwReadImage}.
\end{refdescription}

\begin{refnotes}
\textbf{glfwReadMemoryImage} supports the Truevision Targa version 1 file
format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted
(24/32-bit color), 24-bit true color and 32-bit true color + alpha.

Paletted images are translated into true color or true color + alpha pixel
formats.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwFreeImage}

\textbf{C language syntax}
\begin{lstlisting}
void glfwFreeImage( GLFWimage *img )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{img}]\ \\
  Pointer to a GLFWimage struct.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function frees any memory occupied by a loaded image, and clears all
the fields of the GLFWimage struct. Any image that has been loaded by the
\textbf{glfwReadImage} function should be deallocated using this function
once the image is no longer needed.
\end{refdescription}


%-------------------------------------------------------------------------
\begin{table}[p]
\begin{center}
\begin{tabular}{|l|p{9.0cm}|} \hline \raggedright
\textbf{Name}             & \textbf{Description}\\ \hline
GLFW\_BUILD\_MIPMAPS\_BIT & Automatically build and upload all mipmap levels\\ \hline
GLFW\_ORIGIN\_UL\_BIT     & Specifies that the origin of the \textit{loaded} image should be in the upper left corner (default is the lower left corner)\\ \hline
GLFW\_ALPHA\_MAP\_BIT     & Treat single component images as alpha maps rather than luminance maps\\ \hline
\end{tabular}
\end{center}
\caption{Flags for \textbf{glfwLoadTexture2D}}
\label{tab:ldtexflags}
\end{table}


%-------------------------------------------------------------------------
\subsection{glfwLoadTexture2D}

\textbf{C language syntax}
\begin{lstlisting}
int glfwLoadTexture2D( const char *name, int flags )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{name}]\ \\
  An ISO~8859-1 string holding the name of the file that should be loaded.
\item [\textit{flags}]\ \\
  Flags for controlling the texture loading process. Valid flags are
  listed in table \ref{tab:ldtexflags}.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the texture was loaded successfully.
Otherwise GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
This function reads an image from the file specified by the parameter
\textit{name} and uploads the image to \OpenGL\ texture memory (using the
\textbf{glTexImage2D} function).

If the GLFW\_BUILD\_MIPMAPS\_BIT flag is set, all mipmap levels for the
loaded texture are generated and uploaded to texture memory.

Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the origin of the texture
is the lower left corner of the loaded image. If the flag
GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
corner.

For single component images (i.e. gray scale), the texture is uploaded as
an alpha mask if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
it is uploaded as a luminance texture.
\end{refdescription}

\begin{refnotes}
\textbf{glfwLoadTexture2D} supports the Truevision Targa version 1 file
format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit
paletted (24/32-bit color), 24-bit true color and 32-bit true color +
alpha.

Paletted images are translated into true color or true color + alpha pixel
formats.

The read texture is always rescaled to the nearest larger $2^m\times2^n$
resolution using bilinear interpolation, if necessary, since \OpenGL\
requires textures to have a $2^m\times2^n$ resolution.

If the GL\_SGIS\_generate\_mipmap extension, which is usually hardware
accelerated, is supported by the \OpenGL\ implementation it will be used
for mipmap generation. Otherwise the mipmaps will be generated by \GLFW\
in software.

Since \OpenGL~1.0 does not support single component alpha maps, alpha map
textures are converted to RGBA format under \OpenGL~1.0 when the
GLFW\_ALPHA\_MAP\_BIT flag is set and the loaded texture is a single
component texture. The red, green and blue components are set to 1.0.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwLoadMemoryTexture2D}

\textbf{C language syntax}
\begin{lstlisting}
int glfwLoadMemoryTexture2D( const void *data, long size, int flags )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{data}]\ \\
  The memory buffer holding the contents of the file that should be loaded.
\item [\textit{size}]\ \\
  The size, in bytes, of the memory buffer.
\item [\textit{flags}]\ \\
  Flags for controlling the texture loading process. Valid flags are
  listed in table \ref{tab:ldtexflags}.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the texture was loaded successfully.
Otherwise GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
This function reads an image from the memory buffer specified by the parameter
\textit{data} and uploads the image to \OpenGL\ texture memory (using the
\textbf{glTexImage2D} function).

If the GLFW\_BUILD\_MIPMAPS\_BIT flag is set, all mipmap levels for the
loaded texture are generated and uploaded to texture memory.

Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the origin of the texture
is the lower left corner of the loaded image. If the flag
GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
corner.

For single component images (i.e. gray scale), the texture is uploaded as
an alpha mask if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
it is uploaded as a luminance texture.
\end{refdescription}

\begin{refnotes}
\textbf{glfwLoadMemoryTexture2D} supports the Truevision Targa version 1 file
format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit
paletted (24/32-bit color), 24-bit true color and 32-bit true color +
alpha.

Paletted images are translated into true color or true color + alpha pixel
formats.

The read texture is always rescaled to the nearest larger $2^m\times2^n$
resolution using bilinear interpolation, if necessary, since \OpenGL\
requires textures to have a $2^m\times2^n$ resolution.

If the GL\_SGIS\_generate\_mipmap extension, which is usually hardware
accelerated, is supported by the \OpenGL\ implementation it will be used
for mipmap generation. Otherwise the mipmaps will be generated by \GLFW\
in software.

Since \OpenGL~1.0 does not support single component alpha maps, alpha map
textures are converted to RGBA format under \OpenGL~1.0 when the
GLFW\_ALPHA\_MAP\_BIT flag is set and the loaded texture is a single
component texture. The red, green and blue components are set to 1.0.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwLoadTextureImage2D}

\textbf{C language syntax}
\begin{lstlisting}
int glfwLoadTextureImage2D( GLFWimage *img, int flags )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{img}]\ \\
  Pointer to a GLFWimage struct holding the information about
  the image to be loaded.
\item [\textit{flags}]\ \\
  Flags for controlling the texture loading process. Valid flags are
  listed in table \ref{tab:ldtexflags}.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the texture was loaded successfully.
Otherwise GL\_FALSE is returned.
\end{refreturn}

\begin{refdescription}
This function uploads the image specified by the parameter \textit{img} to
\OpenGL\ texture memory (using the \textbf{glTexImage2D} function).

If the GLFW\_BUILD\_MIPMAPS\_BIT flag is set, all mipmap levels for the
loaded texture are generated and uploaded to texture memory.

Unless the flag GLFW\_ORIGIN\_UL\_BIT is set, the origin of the texture
is the lower left corner of the loaded image. If the flag
GLFW\_ORIGIN\_UL\_BIT is set, however, the first pixel is the upper left
corner.

For single component images (i.e. gray scale), the texture is uploaded as
an alpha mask if the flag GLFW\_ALPHA\_MAP\_BIT flag is set, otherwise
it is uploaded as a luminance texture.
\end{refdescription}

\begin{refnotes}
\textbf{glfwLoadTextureImage2D} supports the Truevision Targa version 1 file
format (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit
paletted (24/32-bit color), 24-bit true color and 32-bit true color +
alpha.

Paletted images are translated into true color or true color + alpha pixel
formats.

The read texture is always rescaled to the nearest larger $2^m\times2^n$
resolution using bilinear interpolation, if necessary, since \OpenGL\
requires textures to have a $2^m\times2^n$ resolution.

If the GL\_SGIS\_generate\_mipmap extension, which is usually hardware
accelerated, is supported by the \OpenGL\ implementation it will be used
for mipmap generation. Otherwise the mipmaps will be generated by \GLFW\
in software.

Since \OpenGL~1.0 does not support single component alpha maps, alpha map
textures are converted to RGBA format under \OpenGL~1.0 when the
GLFW\_ALPHA\_MAP\_BIT flag is set and the loaded texture is a single
component texture. The red, green and blue components are set to 1.0.
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{OpenGL Extension Support}
One of the great features of \OpenGL\ is its support for extensions, which
allow independent vendors to supply non-standard functionality in their
\OpenGL\ implementations.  As the mechanism for querying extensions varies
among systems, \GLFW\ provides an operating system independent interface for
querying \OpenGL\ version, extensions and entry points.


%-------------------------------------------------------------------------
\subsection{glfwExtensionSupported}

\textbf{C language syntax}
\begin{lstlisting}
int glfwExtensionSupported( const char *extension )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{extension}]\ \\
  A null terminated ISO~8859-1 string containing the name of an \OpenGL\
  extension.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the extension is supported. Otherwise it
returns GL\_FALSE.
\end{refreturn}

\begin{refdescription}
This function does a string search in the list of supported \OpenGL\
extensions to find if the specified extension is listed.
\end{refdescription}

\begin{refnotes}
An \OpenGL\ context must be created before this function can be called
(i.e. an \OpenGL\ window must have been opened with
\textbf{glfwOpenWindow}).

In addition to checking for \OpenGL\ extensions, \GLFW\ also checks for
extensions in the operating system ``glue API'', such as WGL extensions
under Microsoft Windows and GLX extensions under the X Window System.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetProcAddress}

\textbf{C language syntax}
\begin{lstlisting}
void * glfwGetProcAddress( const char *procname )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{procname}]\ \\
  A null terminated ISO~8859-1 string containing the name of an \OpenGL\
  extension function.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the address of the specified \OpenGL\ function, if it
is available.  Otherwise NULL is returned.
\end{refreturn}

\begin{refdescription}
This function acquires the pointer to an \OpenGL\ extension function. Some
(but not all) \OpenGL\ extensions define new API functions, which are
usually not available through normal linking. It is therefore necessary to
get access to those API functions at runtime.
\end{refdescription}

\begin{refnotes}
An \OpenGL\ context must be created before this function can be called
(i.e. an \OpenGL\ window must have been opened with
\textbf{glfwOpenWindow}).

Some systems do not support dynamic function pointer retrieval, in which
case \textbf{glfwGetProcAddress} will always return NULL.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwGetGLVersion}

\textbf{C language syntax}
\begin{lstlisting}
void glfwGetGLVersion( int *major, int *minor, int *rev )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{major}]\ \\
  Pointer to an integer that will hold the major version number.
\item [\textit{minor}]\ \\
  Pointer to an integer that will hold the minor version number.
\item [\textit{rev}]\ \\
  Pointer to an integer that will hold the revision.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns the major and minor version numbers and the revision
for the currently used \OpenGL\ implementation.
\end{refreturn}

\begin{refdescription}
This function returns the \OpenGL\ implementation version. This is a
convenient function that parses the version number information at the beginning
of the string returned by calling \texttt{glGetString(~GL\_VERSION~)}. The
\OpenGL\ version information can be used to determine what functionality is
supported by the used \OpenGL\ implementation.
\end{refdescription}

\begin{refnotes}
An \OpenGL\ context must be created before this function can be called
(i.e. an \OpenGL\ window must have been opened with
\textbf{glfwOpenWindow}).
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{Threads}
A thread is a separate execution path within a process. All threads within
a process share the same address space and resources. Threads execute in
parallel, either virtually by means of time-sharing on a single processor,
or truly in parallel on multiple processors. Even on a multi-processor
system, time-sharing is employed in order to maximize processor
utilization and to ensure fair scheduling. \GLFW\ provides an operating
system independent interface to thread management.


%-------------------------------------------------------------------------
\subsection{glfwCreateThread}

\textbf{C language syntax}
\begin{lstlisting}
GLFWthread glfwCreateThread( GLFWthreadfun fun, void *arg )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{fun}]\ \\
  A pointer to a function that acts as the entry point for the new thread.
  The function should have the following C language prototype:

  \texttt{void GLFWCALL functionname( void *arg );}

  Where \textit{functionname} is the name of the thread function, and
  \textit{arg} is the user supplied argument (see below).
\item [\textit{arg}]\ \\
  An arbitrary argument for the thread. \textit{arg} will be passed as the
  argument to the thread function pointed to by \textit{fun}. For
  instance, \textit{arg} can point to data that is to be processed by the
  thread.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns a thread identification number if the thread was
created successfully. This number is always positive. If the function
fails, a negative number is returned.
\end{refreturn}

\begin{refdescription}
This function creates a new thread, which executes within the same address
space as the calling process. The thread entry point is specified with the
\textit{fun} argument.

Once the thread function \textit{fun} returns, the thread dies.
\end{refdescription}

\begin{refnotes}
Even if the function returns a positive thread ID, indicating that the
thread was created successfully, the thread may be unable to execute, for
instance if the thread start address is not a valid thread entry point.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwDestroyThread}

\textbf{C language syntax}
\begin{lstlisting}
void glfwDestroyThread( GLFWthread ID )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{ID}]\ \\
  A thread identification handle, which is returned by
  \textbf{glfwCreateThread} or \textbf{glfwGetThreadID}.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function kills a running thread and removes it from the thread list.
\end{refdescription}

\begin{refnotes}
This function is a very dangerous operation, which may interrupt a thread
in the middle of an important operation, and its use is discouraged. You
should always try to end a thread in a graceful way using thread
communication, and use \textbf{glfwWaitThread} in order to wait for the
thread to die.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwWaitThread}

\textbf{C language syntax}
\begin{lstlisting}
int glfwWaitThread( GLFWthread ID, int waitmode )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{ID}]\ \\
  A thread identification handle, which is returned by
  \textbf{glfwCreateThread} or \textbf{glfwGetThreadID}.
\item [\textit{waitmode}]\ \\
  Can be either GLFW\_WAIT or GLFW\_NOWAIT.
\end{description}
\end{refparameters}

\begin{refreturn}
The function returns GL\_TRUE if the specified thread died after the
function was called, or the thread did not exist, in which case
\textbf{glfwWaitThread} will return immediately regardless of
\textit{waitmode}. The function returns GL\_FALSE if \textit{waitmode}
is GLFW\_NOWAIT, and the specified thread exists and is still running.
\end{refreturn}

\begin{refdescription}
If \textit{waitmode} is GLFW\_WAIT, the function waits for a thread to
die. If \textit{waitmode} is GLFW\_NOWAIT, the function checks if a thread
exists and returns immediately.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwGetThreadID}

\textbf{C language syntax}
\begin{lstlisting}
GLFWthread glfwGetThreadID( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
The function returns a thread identification handle for the calling
thread.
\end{refreturn}

\begin{refdescription}
This function determines the thread ID for the calling thread. The ID is
the same value as was returned by \textbf{glfwCreateThread} when the
thread was created.
\end{refdescription}


%-------------------------------------------------------------------------
\pagebreak
\section{Mutexes}
Mutexes are used to securely share data between threads. A mutex object
can only be owned by one thread at a time. If more than one thread
requires access to a mutex object, all but one thread will be put to sleep
until they get access to it.


%-------------------------------------------------------------------------
\subsection{glfwCreateMutex}

\textbf{C language syntax}
\begin{lstlisting}
GLFWmutex glfwCreateMutex( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
The function returns a mutex handle, or NULL if the mutex could not be
created.
\end{refreturn}

\begin{refdescription}
This function creates a mutex object, which can be used to control access
to data that is shared between threads.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwDestroyMutex}

\textbf{C language syntax}
\begin{lstlisting}
void glfwDestroyMutex( GLFWmutex mutex )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{mutex}]\ \\
  A mutex object handle.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function destroys a mutex object. After a mutex object has been
destroyed, it may no longer be used by any thread.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwLockMutex}

\textbf{C language syntax}
\begin{lstlisting}
void glfwLockMutex( GLFWmutex mutex )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{mutex}]\ \\
  A mutex object handle.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function will acquire a lock on the selected mutex object. If the
mutex is already locked by another thread, the function will block the
calling thread until it is released by the locking thread. Once the
function returns, the calling thread has an exclusive lock on the mutex.
To release the mutex, call \textbf{glfwUnlockMutex}.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwUnlockMutex}

\textbf{C language syntax}
\begin{lstlisting}
void glfwUnlockMutex( GLFWmutex mutex )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{mutex}]\ \\
  A mutex object handle.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function releases the lock of a locked mutex object.
\end{refdescription}


%-------------------------------------------------------------------------
\pagebreak
\section{Condition Variables}
Condition variables are used to synchronize threads. A thread can wait for
a condition variable to be signaled by another thread.


%-------------------------------------------------------------------------
\subsection{glfwCreateCond}

\textbf{C language syntax}
\begin{lstlisting}
GLFWcond glfwCreateCond( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
The function returns a condition variable handle, or NULL if the condition
variable could not be created.
\end{refreturn}

\begin{refdescription}
This function creates a condition variable object, which can be used to
synchronize threads.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwDestroyCond}

\textbf{C language syntax}
\begin{lstlisting}
void glfwDestroyCond( GLFWcond cond )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cond}]\ \\
  A condition variable object handle.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function destroys a condition variable object. After a condition
variable object has been destroyed, it may no longer be used by any
thread.
\end{refdescription}


%-------------------------------------------------------------------------
\subsection{glfwWaitCond}

\textbf{C language syntax}
\begin{lstlisting}
void glfwWaitCond( GLFWcond cond, GLFWmutex mutex, double timeout )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cond}]\ \\
  A condition variable object handle.
\item [\textit{mutex}]\ \\
  A mutex object handle.
\item [\textit{timeout}]\ \\
  Maximum time to wait for the condition variable. The parameter can
  either be a positive time (in seconds), or GLFW\_INFINITY.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function atomically unlocks the mutex specified by \textit{mutex}, and
waits for the condition variable \textit{cond} to be signaled. The thread
execution is suspended and does not consume any CPU time until the
condition variable is signaled or the amount of time specified by timeout
has passed. If timeout is GLFW\_INFINITY, \textbf{glfwWaitCond} will wait
forever for \textit{cond} to be signaled. Before returning to the calling
thread, \textbf{glfwWaitCond} automatically re-acquires the mutex.
\end{refdescription}

\begin{refnotes}
The mutex specified by \textit{mutex} must be locked by the calling thread
before entrance to \textbf{glfwWaitCond}.

A condition variable must always be associated with a mutex, to avoid the
race condition where a thread prepares to wait on a condition variable and
another thread signals the condition just before the first thread actually
waits on it.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwSignalCond}

\textbf{C language syntax}
\begin{lstlisting}
void glfwSignalCond( GLFWcond cond )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cond}]\ \\
  A condition variable object handle.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function restarts one of the threads that are waiting on the condition
variable \textit{cond}. If no threads are waiting on \textit{cond},
nothing happens. If several threads are waiting on \textit{cond}, exactly
one is restarted, but it is not specified which.
\end{refdescription}

\begin{refnotes}
When several threads are waiting for the condition variable, which thread
is started depends on operating system scheduling rules, and may vary from
system to system and from time to time.
\end{refnotes}


%-------------------------------------------------------------------------
\subsection{glfwBroadcastCond}

\textbf{C language syntax}
\begin{lstlisting}
void glfwBroadcastCond( GLFWcond cond )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{cond}]\ \\
  A condition variable object handle.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
This function restarts all the threads that are waiting on the condition
variable \textit{cond}. If no threads are waiting on \textit{cond},
nothing happens.
\end{refdescription}

\begin{refnotes}
When several threads are waiting for the condition variable, the order in
which threads are started depends on operating system scheduling rules,
and may vary from system to system and from time to time.
\end{refnotes}


%-------------------------------------------------------------------------
\pagebreak
\section{Miscellaneous}


%-------------------------------------------------------------------------
\subsection{glfwEnable/glfwDisable}

\textbf{C language syntax}
\begin{lstlisting}
void glfwEnable( int token )
void glfwDisable( int token )
\end{lstlisting}

\begin{refparameters}
\begin{description}
\item [\textit{token}]\ \\
  A value specifying a feature to enable or disable. Valid tokens are
  listed in table \ref{tab:enable}.
\end{description}
\end{refparameters}

\begin{refreturn}
none
\end{refreturn}

\begin{refdescription}
\textbf{glfwEnable} is used to enable a certain feature, while
\textbf{glfwDisable} is used to disable it. Below follows a description of
each feature.
\end{refdescription}


\begin{table}[p]
\begin{center}
\begin{tabular}{|l|p{5.0cm}|p{3.0cm}|} \hline \raggedright
\textbf{Name} & \textbf{Controls} & \textbf{Default}\\ \hline
\hyperlink{lnk:autopollevents}{GLFW\_AUTO\_POLL\_EVENTS}         & Automatic event polling when \textbf{glfwSwapBuffers} is called & Enabled\\ \hline
\hyperlink{lnk:keyrepeat}{GLFW\_KEY\_REPEAT}                     & Keyboard key repeat                                    & Disabled\\ \hline
\hyperlink{lnk:mousecursor}{GLFW\_MOUSE\_CURSOR}                 & Mouse cursor visibility                                & Enabled in windowed mode. Disabled in fullscreen mode.\\ \hline
\hyperlink{lnk:stickykeys}{GLFW\_STICKY\_KEYS}                   & Keyboard key ``stickiness''                            & Disabled\\ \hline
\hyperlink{lnk:stickymousebuttons}{GLFW\_STICKY\_MOUSE\_BUTTONS} & Mouse button ``stickiness''                            & Disabled\\ \hline
\hyperlink{lnk:systemkeys}{GLFW\_SYSTEM\_KEYS}                   & Special system key actions                             & Enabled\\ \hline
\end{tabular}
\end{center}
\caption{Tokens for \textbf{glfwEnable}/\textbf{glfwDisable}}
\label{tab:enable}
\end{table}


\bigskip\begin{mysamepage}\hypertarget{lnk:autopollevents}{}
\textbf{GLFW\_AUTO\_POLL\_EVENTS}\\
When GLFW\_AUTO\_POLL\_EVENTS is enabled, \textbf{glfwPollEvents} is
automatically called each time that \textbf{glfwSwapBuffers} is called,
immediately after the buffer swap itself.

When GLFW\_AUTO\_POLL\_EVENTS is disabled, calling
\textbf{glfwSwapBuffers} will not result in a call to
\textbf{glfwPollEvents}. This can be useful if for example \textbf{glfwSwapBuffers}
needs to be called from within a callback function, since calling
\textbf{glfwPollEvents} from a callback function is not allowed.
\end{mysamepage}


\bigskip\begin{mysamepage}\hypertarget{lnk:keyrepeat}{}
\textbf{GLFW\_KEY\_REPEAT}\\
When GLFW\_KEY\_REPEAT is enabled, the key and character callback
functions are called repeatedly when a key is held down long enough
(according to the system key repeat configuration).

When GLFW\_KEY\_REPEAT is disabled, the key and character callback
functions are only called once when a key is pressed (and once when it is
released).
\end{mysamepage}


\bigskip\begin{mysamepage}\hypertarget{lnk:mousecursor}{}
\textbf{GLFW\_MOUSE\_CURSOR}\\
When GLFW\_MOUSE\_CURSOR is enabled, the mouse cursor is visible, and
mouse coordinates are relative to the upper left corner of the client area
of the \GLFW\ window. The coordinates are limited to the client area of
the window.

When GLFW\_MOUSE\_CURSOR is disabled, the mouse cursor is invisible, and
mouse coordinates are not limited to the drawing area of the window. It is
as if the mouse coordinates are received directly from the mouse, without
being restricted or manipulated by the windowing system.
\end{mysamepage}


\bigskip\begin{mysamepage}\hypertarget{lnk:stickykeys}{}
\textbf{GLFW\_STICKY\_KEYS}\\
When GLFW\_STICKY\_KEYS is enabled, keys which are pressed will not be
released until they are physically released and checked with
\textbf{glfwGetKey}. This behavior makes it possible to catch keys that
were pressed and then released again between two calls to
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or
\textbf{glfwSwapBuffers}, which would otherwise have been reported as
released. Care should be taken when using this mode, since keys that are
not checked with \textbf{glfwGetKey} will never be released. Note also
that enabling GLFW\_STICKY\_KEYS does not affect the behavior of the
keyboard callback functionality.

When GLFW\_STICKY\_KEYS is disabled, the status of a key that is reported
by \textbf{glfwGetKey} is always the physical state of the key. Disabling
GLFW\_STICKY\_KEYS also clears the sticky information for all keys.
\end{mysamepage}


\bigskip\begin{mysamepage}\hypertarget{lnk:stickymousebuttons}{}
\textbf{GLFW\_STICKY\_MOUSE\_BUTTONS}\\
When GLFW\_STICKY\_MOUSE\_BUTTONS is enabled, mouse buttons that are pressed
will not be released until they are physically released and checked with
\textbf{glfwGetMouseButton}. This behavior makes it possible to catch mouse
buttons which were pressed and then released again between two calls to
\textbf{glfwPollEvents}, \textbf{glfwWaitEvents} or \textbf{glfwSwapBuffers}
(with GLFW\_AUTO\_POLL\_EVENTS enabled), which would otherwise have been
reported as released. Care should be taken when using this mode, since mouse
buttons that are not checked with \textbf{glfwGetMouseButton} will never be
released. Note also that enabling GLFW\_STICKY\_MOUSE\_BUTTONS does not affect
the behavior of the mouse button callback functionality.

When GLFW\_STICKY\_MOUSE\_BUTTONS is disabled, the status of a mouse
button that is reported by \textbf{glfwGetMouseButton} is always the
physical state of the mouse button. Disabling GLFW\_STICKY\_MOUSE\_BUTTONS
also clears the sticky information for all mouse buttons.
\end{mysamepage}


\bigskip\begin{mysamepage}\hypertarget{lnk:systemkeys}{}
\textbf{GLFW\_SYSTEM\_KEYS}\\
When GLFW\_SYSTEM\_KEYS is enabled, pressing standard system key
combinations, such as \texttt{Alt+Tab} under Windows, will give the normal
behavior. Note that when \texttt{Alt+Tab} is issued under Windows in this
mode so that the \GLFW\ application is deselected when \GLFW\ is operating
in fullscreen mode, the \GLFW\ application window will be minimized and
the video mode will be set to the original desktop mode. When the \GLFW\
application is re-selected, the video mode will be set to the \GLFW\ video
mode again.

When GLFW\_SYSTEM\_KEYS is disabled, pressing standard system key
combinations will have no effect, since those key combinations are blocked
by \GLFW . This mode can be useful in situations when the \GLFW\ program
must not be interrupted (normally for games in fullscreen mode).
\end{mysamepage}


%-------------------------------------------------------------------------
\subsection{glfwGetNumberOfProcessors}

\textbf{C language syntax}
\begin{lstlisting}
int glfwGetNumberOfProcessors( void )
\end{lstlisting}

\begin{refparameters}
none
\end{refparameters}

\begin{refreturn}
The function returns the number of active processors in the system.
\end{refreturn}

\begin{refdescription}
This function determines the number of active processors in the system.
\end{refdescription}

\begin{refnotes}
Systems with several logical processors per physical processor, also
known as SMT (Symmetric Multi-Threading) processors, will report the
number of logical processors.
\end{refnotes}


%-------------------------------------------------------------------------
% GLFW Standards Conformance
%-------------------------------------------------------------------------
\appendix
\chapter{GLFW Compatibility}
\label{chap:compatibility}
\thispagestyle{fancy}

This chapter describes the various API extensions used by this version of
\GLFW .  It lists what are essentially implementation details, but which are
nonetheless vital knowledge for developers wishing to deploy their applications
on machines with varied specifications.

Note that the information in this appendix is not a part of the API
specification but merely list some of the preconditions for certain parts of
the API to function on a given machine.  As such, any part of it may change in
future versions without this being considered a breaking API change.

%-------------------------------------------------------------------------
\section{ICCCM and EWMH Conformance}

As \GLFW\ uses \textbf{Xlib}, directly, without any intervening toolkit
library, it has sole responsibility for interacting well with the many and
varied window managers in use on Unix-like systems.  In order for applications
and window managers to work well together, a number of standards and
conventions have been developed that regulate behavior outside the scope of the
X11 API; most importantly the \textbf{Inter-Client Communication Conventions
Manual} (ICCCM) and \textbf{Extended Window Manager Hints} (EWMH) standards.

\GLFW\ uses the ICCCM \textbf{WM\_DELETE\_WINDOW} protocol to intercept the user
attempting to close the \GLFW\ window.  If the running window manager does not
support this protocol, the close callback will never be called.

\GLFW\ uses the EWMH \textbf{\_NET\_WM\_PING} protocol, allowing the window
manager notify the user when the application has stopped responding, i.e. when
it has ceased to process events.  If the running window manager does not
support this protocol, the user will not be notified if the application locks
up.

\GLFW\ uses the EWMH \textbf{\_NET\_WM\_STATE} protocol to tell the window
manager to make the \GLFW\ window fullscreen.  If the running window manager
does not support this protocol, fullscreen windows may not work properly.
\GLFW\ has a fallback code path in case this protocol is unavailable, but every
window manager behaves slightly differently in this regard.

%-------------------------------------------------------------------------
\section{GLX Extensions}

The \textbf{GLX} API is used to create \OpenGL\ contexts on Unix-like systems
using the X Window System.

\GLFW\ uses the \textbf{GLXFBConfig} API to enumerate and select framebuffer
pixel formats.  This requires either \textbf{GLX} 1.3 or greater, or the
\textbf{GLX\_SGIX\_fbconfig} extension.  Where both are available, the SGIX
extension is preferred.  If neither is available, \GLFW\ will be unable to open
windows.

% This paragraph repeated almost verbatim below
\GLFW\ uses the \textbf{GLX\_SGI\_swap\_control} extension to provide vertical
retrace synchronization (or ``vsync'').  Where this extension is unavailable,
calling \textbf{glfwSwapInterval} will have no effect.

% This paragraph repeated almost verbatim below
\GLFW\ uses the \textbf{GLX\_ARB\_multisample} extension to create contexts
with multisampling anti-aliasing.  Where this extension is unavailable, the
GLFW\_FSAA\_SAMPLES hint will have no effect.

% This paragraph repeated almost verbatim below
\GLFW\ uses the \textbf{GLX\_ARB\_create\_context} extension when available,
even when creating \OpenGL\ contexts of version 2.1 and below.  Where this
extension is unavailable, the GLFW\_OPENGL\_VERSION\_MAJOR and
GLFW\_OPENGL\_VERSION\_MINOR hints will only be partially supported, the
GLFW\_OPENGL\_DEBUG\_CONTEXT hint will have no effect, and setting the
GLFW\_OPENGL\_PROFILE or GLFW\_FORWARD\_COMPAT hints to a non-zero value will
cause \textbf{glfwOpenWindow} to fail.

% This paragraph repeated almost verbatim below
\GLFW\ uses the \textbf{GLX\_ARB\_create\_context\_profile} extension to
provide support for context profiles.  Where this extension is unavailable,
setting the GLFW\_OPENGL\_PROFILE hint to anything but zero will cause
\textbf{glfwOpenWindow} to fail.

%-------------------------------------------------------------------------
\section{WGL Extensions}

The \textbf{WGL} API is used to create \OpenGL\ contexts on Microsoft Windows
and other implementations of the Win32 API, such as Wine.

\GLFW\ uses either the \textbf{WGL\_EXT\_extension\_string} or the
\textbf{WGL\_ARB\_extension\_string} extension to check for the presence of all
other \textbf{WGL} extensions listed below.  If both are available, the EXT one
is preferred.  If neither is available, no other extensions are used and many
\GLFW\ features related to context creation will have no effect or cause errors
when used.

% This paragraph repeated almost verbatim above
\GLFW\ uses the \textbf{WGL\_EXT\_swap\_control} extension to provide vertical
retrace synchronization (or ``vsync'').  Where this extension is unavailable,
calling \textbf{glfwSwapInterval} will have no effect.

% This paragraph repeated almost verbatim above
\GLFW\ uses the \textbf{WGL\_ARB\_pixel\_format} and
\textbf{WGL\_ARB\_multisample} extensions to create contexts with multisampling
anti-aliasing.  Where these extensions are unavailable, the GLFW\_FSAA\_SAMPLES
hint will have no effect.

% This paragraph repeated almost verbatim above
\GLFW\ uses the \textbf{WGL\_ARB\_create\_context} extension when available,
even when creating \OpenGL\ contexts of version 2.1 and below.  Where this
extension is unavailable, the GLFW\_OPENGL\_VERSION\_MAJOR and
GLFW\_OPENGL\_VERSION\_MINOR hints will only be partially supported, the
GLFW\_OPENGL\_DEBUG\_CONTEXT hint will have no effect, and setting the
GLFW\_OPENGL\_PROFILE or GLFW\_FORWARD\_COMPAT hints to a non-zero value will
cause \textbf{glfwOpenWindow} to fail.

% This paragraph repeated almost verbatim above
\GLFW\ uses the \textbf{WGL\_ARB\_create\_context\_profile} extension to
provide support for context profiles.  Where this extension is unavailable,
setting the GLFW\_OPENGL\_PROFILE hint to anything but zero will cause
\textbf{glfwOpenWindow} to fail.

%-------------------------------------------------------------------------
\section{OpenGL 3.0+ on Mac OS X}

Support for OpenGL 3.0 and above was introduced with Mac OS X 10.7, and even
then forward-compatible OpenGL 3.2 core profile contexts are supported and
there is no mechanism for requesting debug contexts.  Earlier versions of Mac
OS X supports at most OpenGL version 2.1.

Because of this, on Mac OS X 10.7, the GLFW\_OPENGL\_VERSION\_MAJOR and
GLFW\_OPENGL\_VERSION\_MINOR hints will fail if given a version above 3.2, the
GLFW\_OPENGL\_DEBUG\_CONTEXT and GLFW\_FORWARD\_COMPAT hints are ignored, and
setting the GLFW\_OPENGL\_PROFILE hint to anything except zero or
GLFW\_OPENGL\_CORE\_PROFILE will cause \textbf{glfwOpenWindow} to fail.                      

Also, on Mac OS X 10.6 and below, the GLFW\_OPENGL\_VERSION\_MAJOR and
GLFW\_OPENGL\_VERSION\_MINOR hints will fail if given a version above 2.1, the
GLFW\_OPENGL\_DEBUG\_CONTEXT hint will have no effect, and setting the
GLFW\_OPENGL\_PROFILE or GLFW\_FORWARD\_COMPAT hints to a non-zero value will
cause \textbf{glfwOpenWindow} to fail.


\end{document}