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
|
/* $XFree86: xc/lib/GL/glx/glxcmds.c,v 1.17 2002/02/27 21:09:32 tsi Exp $ */
/*
** License Applicability. Except to the extent portions of this file are
** made subject to an alternative license as permitted in the SGI Free
** Software License B, Version 1.1 (the "License"), the contents of this
** file are subject only to the provisions of the License. You may not use
** this file except in compliance with the License. You may obtain a copy
** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
**
** http://oss.sgi.com/projects/FreeB
**
** Note that, as provided in the License, the Software is distributed on an
** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
**
** Original Code. The Original Code is: OpenGL Sample Implementation,
** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
** Copyright in any portions created by third parties is as indicated
** elsewhere herein. All Rights Reserved.
**
** Additional Notice Provisions: The application programming interfaces
** established by SGI in conjunction with the Original Code are The
** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
** Window System(R) (Version 1.3), released October 19, 1998. This software
** was created using the OpenGL(R) version 1.2.1 Sample Implementation
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
*/
#include "packsingle.h"
#include "glxclient.h"
#include <extutil.h>
#include <Xext.h>
#include <string.h>
#include "glapi.h"
#ifdef GLX_DIRECT_RENDERING
#include "indirect_init.h"
#endif
static const char __glXGLClientExtensions[] =
"GL_ARB_imaging "
"GL_ARB_multitexture "
"GL_ARB_texture_border_clamp "
"GL_ARB_texture_cube_map "
"GL_ARB_texture_env_add "
"GL_ARB_texture_env_combine "
"GL_ARB_texture_env_dot3 "
"GL_ARB_transpose_matrix "
"GL_EXT_abgr "
"GL_EXT_blend_color "
"GL_EXT_blend_minmax "
"GL_EXT_blend_subtract "
"GL_EXT_texture_env_add "
"GL_EXT_texture_env_combine "
"GL_EXT_texture_env_dot3 "
"GL_EXT_texture_lod_bias "
;
static const char __glXGLXClientVendorName[] = "SGI";
static const char __glXGLXClientVersion[] = "1.2";
static const char __glXGLXClientExtensions[] =
"GLX_EXT_visual_info "
"GLX_EXT_visual_rating "
"GLX_EXT_import_context "
;
/*
** Create a new context.
*/
static
GLXContext CreateContext(Display *dpy, XVisualInfo *vis,
GLXContext shareList,
Bool allowDirect, GLXContextID contextID)
{
xGLXCreateContextReq *req;
GLXContext gc;
int bufSize = XMaxRequestSize(dpy) * 4;
CARD8 opcode;
#ifdef GLX_DIRECT_RENDERING
__GLXdisplayPrivate *priv;
#endif
if (!dpy || !vis)
return NULL;
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return NULL;
}
/* Allocate our context record */
gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec));
if (!gc) {
/* Out of memory */
return NULL;
}
memset(gc, 0, sizeof(struct __GLXcontextRec));
/* Allocate transport buffer */
gc->buf = (GLubyte *) Xmalloc(bufSize);
if (!gc->buf) {
Xfree(gc);
return NULL;
}
gc->bufSize = bufSize;
/* Fill in the new context */
gc->renderMode = GL_RENDER;
gc->state.storePack.alignment = 4;
gc->state.storeUnpack.alignment = 4;
__glXInitVertexArrayState(gc);
gc->attributes.stackPointer = &gc->attributes.stack[0];
/*
** PERFORMANCE NOTE: A mode dependent fill image can speed things up.
** Other code uses the fastImageUnpack bit, but it is never set
** to GL_TRUE.
*/
gc->fastImageUnpack = GL_FALSE;
gc->fillImage = __glFillImage;
gc->isDirect = GL_FALSE;
gc->pc = gc->buf;
gc->bufEnd = gc->buf + bufSize;
if (__glXDebug) {
/*
** Set limit register so that there will be one command per packet
*/
gc->limit = gc->buf;
} else {
gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
}
gc->createDpy = dpy;
gc->majorOpcode = opcode;
/*
** Constrain the maximum drawing command size allowed to be
** transfered using the X_GLXRender protocol request. First
** constrain by a software limit, then constrain by the protocl
** limit.
*/
if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
}
if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
bufSize = __GLX_MAX_RENDER_CMD_SIZE;
}
gc->maxSmallRenderCommandSize = bufSize;
if (None == contextID) {
#ifdef GLX_DIRECT_RENDERING
/*
** Create the direct rendering context, if requested and
** available.
*/
priv = __glXInitialize(dpy);
if (allowDirect && priv->driDisplay.private) {
__GLXscreenConfigs *psc = &priv->screenConfigs[vis->screen];
if (psc && psc->driScreen.private) {
void *shared = (shareList ?
shareList->driContext.private : NULL);
gc->driContext.private =
(*psc->driScreen.createContext)(dpy, vis, shared,
&gc->driContext);
if (gc->driContext.private) {
gc->isDirect = GL_TRUE;
gc->screen = vis->screen;
gc->vid = vis->visualid;
}
}
}
#endif
/* Send the glXCreateContext request */
LockDisplay(dpy);
GetReq(GLXCreateContext,req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXCreateContext;
req->context = gc->xid = XAllocID(dpy);
req->visual = vis->visualid;
req->screen = vis->screen;
req->shareList = shareList ? shareList->xid : None;
req->isDirect = gc->isDirect;
UnlockDisplay(dpy);
SyncHandle();
gc->imported = GL_FALSE;
}
else {
gc->xid = contextID;
gc->imported = GL_TRUE;
}
return gc;
}
GLXContext GLX_PREFIX(glXCreateContext)(Display *dpy, XVisualInfo *vis,
GLXContext shareList, Bool allowDirect)
{
return CreateContext(dpy, vis, shareList, allowDirect, None);
}
void __glXFreeContext(__GLXcontext *gc)
{
if (gc->vendor) XFree((char *) gc->vendor);
if (gc->renderer) XFree((char *) gc->renderer);
if (gc->version) XFree((char *) gc->version);
if (gc->extensions) XFree((char *) gc->extensions);
__glFreeAttributeState(gc);
XFree((char *) gc->buf);
XFree((char *) gc);
}
/*
** Destroy the named context
*/
static void
DestroyContext(Display *dpy, GLXContext gc)
{
xGLXDestroyContextReq *req;
GLXContextID xid;
CARD8 opcode;
GLboolean imported;
opcode = __glXSetupForCommand(dpy);
if (!opcode || !gc) {
return;
}
__glXLock();
xid = gc->xid;
imported = gc->imported;
gc->xid = None;
#ifdef GLX_DIRECT_RENDERING
/* Destroy the direct rendering context */
if (gc->isDirect) {
if (gc->driContext.private) {
(*gc->driContext.destroyContext)(dpy, gc->screen,
gc->driContext.private);
gc->driContext.private = NULL;
}
}
#endif
if (gc->currentDpy) {
/* Have to free later cuz it's in use now */
__glXUnlock();
} else {
/* Destroy the handle if not current to anybody */
__glXUnlock();
__glXFreeContext(gc);
}
if (!imported) {
/*
** This dpy also created the server side part of the context.
** Send the glXDestroyContext request.
*/
LockDisplay(dpy);
GetReq(GLXDestroyContext,req);
req->reqType = opcode;
req->glxCode = X_GLXDestroyContext;
req->context = xid;
UnlockDisplay(dpy);
SyncHandle();
}
}
void GLX_PREFIX(glXDestroyContext)(Display *dpy, GLXContext gc)
{
DestroyContext(dpy, gc);
}
/*
** Return the major and minor version #s for the GLX extension
*/
Bool GLX_PREFIX(glXQueryVersion)(Display *dpy, int *major, int *minor)
{
__GLXdisplayPrivate *priv;
/* Init the extension. This fetches the major and minor version. */
priv = __glXInitialize(dpy);
if (!priv) return GL_FALSE;
if (major) *major = priv->majorVersion;
if (minor) *minor = priv->minorVersion;
return GL_TRUE;
}
/*
** Query the existance of the GLX extension
*/
Bool GLX_PREFIX(glXQueryExtension)(Display *dpy, int *errorBase, int *eventBase)
{
int major_op, erb, evb;
Bool rv;
rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb);
if (rv) {
if (errorBase) *errorBase = erb;
if (eventBase) *eventBase = evb;
}
return rv;
}
/*
** Put a barrier in the token stream that forces the GL to finish its
** work before X can proceed.
*/
void GLX_PREFIX(glXWaitGL)(void)
{
xGLXWaitGLReq *req;
GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
if (!dpy) return;
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_DIRECT_RENDERING
if (gc->isDirect) {
/* This bit of ugliness unwraps the glFinish function */
#ifdef glFinish
#undef glFinish
#endif
glFinish();
return;
}
#endif
/* Send the glXWaitGL request */
LockDisplay(dpy);
GetReq(GLXWaitGL,req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXWaitGL;
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
}
/*
** Put a barrier in the token stream that forces X to finish its
** work before GL can proceed.
*/
void GLX_PREFIX(glXWaitX)(void)
{
xGLXWaitXReq *req;
GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
if (!dpy) return;
/* Flush any pending commands out */
__glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_DIRECT_RENDERING
if (gc->isDirect) {
XSync(dpy, False);
return;
}
#endif
/*
** Send the glXWaitX request.
*/
LockDisplay(dpy);
GetReq(GLXWaitX,req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXWaitX;
req->contextTag = gc->currentContextTag;
UnlockDisplay(dpy);
SyncHandle();
}
void GLX_PREFIX(glXUseXFont)(Font font, int first, int count, int listBase)
{
xGLXUseXFontReq *req;
GLXContext gc = __glXGetCurrentContext();
Display *dpy = gc->currentDpy;
if (!dpy) return;
/* Flush any pending commands out */
(void) __glXFlushRenderBuffer(gc, gc->pc);
#ifdef GLX_DIRECT_RENDERING
if (gc->isDirect) {
DRI_glXUseXFont(font, first, count, listBase);
return;
}
#endif
/* Send the glXUseFont request */
LockDisplay(dpy);
GetReq(GLXUseXFont,req);
req->reqType = gc->majorOpcode;
req->glxCode = X_GLXUseXFont;
req->contextTag = gc->currentContextTag;
req->font = font;
req->first = first;
req->count = count;
req->listBase = listBase;
UnlockDisplay(dpy);
SyncHandle();
}
/************************************************************************/
/*
** Copy the source context to the destination context using the
** attribute "mask".
*/
void GLX_PREFIX(glXCopyContext)(Display *dpy, GLXContext source, GLXContext dest,
unsigned long mask)
{
xGLXCopyContextReq *req;
GLXContext gc = __glXGetCurrentContext();
GLXContextTag tag;
CARD8 opcode;
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return;
}
#ifdef GLX_DIRECT_RENDERING
if (gc->isDirect) {
/* NOT_DONE: This does not work yet */
}
#endif
/*
** If the source is the current context, send its tag so that the context
** can be flushed before the copy.
*/
if (source == gc && dpy == gc->currentDpy) {
tag = gc->currentContextTag;
} else {
tag = 0;
}
/* Send the glXCopyContext request */
LockDisplay(dpy);
GetReq(GLXCopyContext,req);
req->reqType = opcode;
req->glxCode = X_GLXCopyContext;
req->source = source ? source->xid : None;
req->dest = dest ? dest->xid : None;
req->mask = mask;
req->contextTag = tag;
UnlockDisplay(dpy);
SyncHandle();
}
/*
** Return GL_TRUE if the context is direct rendering or not.
*/
static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
{
xGLXIsDirectReq *req;
xGLXIsDirectReply reply;
CARD8 opcode;
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return GL_FALSE;
}
/* Send the glXIsDirect request */
LockDisplay(dpy);
GetReq(GLXIsDirect,req);
req->reqType = opcode;
req->glxCode = X_GLXIsDirect;
req->context = contextID;
_XReply(dpy, (xReply*) &reply, 0, False);
UnlockDisplay(dpy);
SyncHandle();
return reply.isDirect;
}
Bool GLX_PREFIX(glXIsDirect)(Display *dpy, GLXContext gc)
{
if (!gc) {
return GL_FALSE;
#ifdef GLX_DIRECT_RENDERING
} else if (gc->isDirect) {
return GL_TRUE;
#endif
}
return __glXIsDirect(dpy, gc->xid);
}
GLXPixmap GLX_PREFIX(glXCreateGLXPixmap)(Display *dpy, XVisualInfo *vis, Pixmap pixmap)
{
xGLXCreateGLXPixmapReq *req;
GLXPixmap xid;
CARD8 opcode;
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return None;
}
/* Send the glXCreateGLXPixmap request */
LockDisplay(dpy);
GetReq(GLXCreateGLXPixmap,req);
req->reqType = opcode;
req->glxCode = X_GLXCreateGLXPixmap;
req->screen = vis->screen;
req->visual = vis->visualid;
req->pixmap = pixmap;
req->glxpixmap = xid = XAllocID(dpy);
UnlockDisplay(dpy);
SyncHandle();
return xid;
}
/*
** Destroy the named pixmap
*/
void GLX_PREFIX(glXDestroyGLXPixmap)(Display *dpy, GLXPixmap glxpixmap)
{
xGLXDestroyGLXPixmapReq *req;
CARD8 opcode;
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return;
}
/* Send the glXDestroyGLXPixmap request */
LockDisplay(dpy);
GetReq(GLXDestroyGLXPixmap,req);
req->reqType = opcode;
req->glxCode = X_GLXDestroyGLXPixmap;
req->glxpixmap = glxpixmap;
UnlockDisplay(dpy);
SyncHandle();
}
void GLX_PREFIX(glXSwapBuffers)(Display *dpy, GLXDrawable drawable)
{
xGLXSwapBuffersReq *req;
GLXContext gc = __glXGetCurrentContext();
GLXContextTag tag;
CARD8 opcode;
#ifdef GLX_DIRECT_RENDERING
__GLXdisplayPrivate *priv;
__DRIdrawable *pdraw;
priv = __glXInitialize(dpy);
if (priv->driDisplay.private) {
__GLXscreenConfigs *psc = &priv->screenConfigs[gc->screen];
if (psc && psc->driScreen.private) {
/*
** getDrawable returning NULL implies that the drawable is
** not bound to a direct rendering context.
*/
pdraw = (*psc->driScreen.getDrawable)(dpy, drawable,
psc->driScreen.private);
if (pdraw) {
(*pdraw->swapBuffers)(dpy, pdraw->private);
return;
}
}
}
#endif
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return;
}
/*
** The calling thread may or may not have a current context. If it
** does, send the context tag so the server can do a flush.
*/
if ((dpy == gc->currentDpy) && (drawable == gc->currentDrawable)) {
tag = gc->currentContextTag;
} else {
tag = 0;
}
/* Send the glXSwapBuffers request */
LockDisplay(dpy);
GetReq(GLXSwapBuffers,req);
req->reqType = opcode;
req->glxCode = X_GLXSwapBuffers;
req->drawable = drawable;
req->contextTag = tag;
UnlockDisplay(dpy);
SyncHandle();
XFlush(dpy);
}
/*
** Return configuration information for the given display, screen and
** visual combination.
*/
int GLX_PREFIX(glXGetConfig)(Display *dpy, XVisualInfo *vis, int attribute,
int *value_return)
{
__GLXvisualConfig *pConfig;
__GLXscreenConfigs *psc;
__GLXdisplayPrivate *priv;
GLint i;
/* Initialize the extension, if needed */
priv = __glXInitialize(dpy);
if (!priv) {
/* No extension */
return GLX_NO_EXTENSION;
}
/* Check screen number to see if its valid */
if ((vis->screen < 0) || (vis->screen >= ScreenCount(dpy))) {
return GLX_BAD_SCREEN;
}
/* Check to see if the GL is supported on this screen */
psc = &priv->screenConfigs[vis->screen];
pConfig = psc->configs;
if (!pConfig) {
/* No support for GL on this screen regardless of visual */
if (attribute == GLX_USE_GL) {
*value_return = GL_FALSE;
return Success;
}
return GLX_BAD_VISUAL;
}
/* Lookup attribute after first finding a match on the visual */
for (i = psc->numConfigs; --i >= 0; pConfig++) {
if (pConfig->vid == vis->visualid) {
switch (attribute) {
case GLX_USE_GL:
*value_return = GL_TRUE;
return Success;
case GLX_BUFFER_SIZE:
*value_return = pConfig->bufferSize;
return Success;
case GLX_RGBA:
*value_return = pConfig->rgba;
return Success;
case GLX_RED_SIZE:
*value_return = pConfig->redSize;
return Success;
case GLX_GREEN_SIZE:
*value_return = pConfig->greenSize;
return Success;
case GLX_BLUE_SIZE:
*value_return = pConfig->blueSize;
return Success;
case GLX_ALPHA_SIZE:
*value_return = pConfig->alphaSize;
return Success;
case GLX_DOUBLEBUFFER:
*value_return = pConfig->doubleBuffer;
return Success;
case GLX_STEREO:
*value_return = pConfig->stereo;
return Success;
case GLX_AUX_BUFFERS:
*value_return = pConfig->auxBuffers;
return Success;
case GLX_DEPTH_SIZE:
*value_return = pConfig->depthSize;
return Success;
case GLX_STENCIL_SIZE:
*value_return = pConfig->stencilSize;
return Success;
case GLX_ACCUM_RED_SIZE:
*value_return = pConfig->accumRedSize;
return Success;
case GLX_ACCUM_GREEN_SIZE:
*value_return = pConfig->accumGreenSize;
return Success;
case GLX_ACCUM_BLUE_SIZE:
*value_return = pConfig->accumBlueSize;
return Success;
case GLX_ACCUM_ALPHA_SIZE:
*value_return = pConfig->accumAlphaSize;
return Success;
case GLX_LEVEL:
*value_return = pConfig->level;
return Success;
case GLX_TRANSPARENT_TYPE_EXT:
*value_return = pConfig->transparentPixel;
return Success;
case GLX_TRANSPARENT_RED_VALUE_EXT:
*value_return = pConfig->transparentRed;
return Success;
case GLX_TRANSPARENT_GREEN_VALUE_EXT:
*value_return = pConfig->transparentGreen;
return Success;
case GLX_TRANSPARENT_BLUE_VALUE_EXT:
*value_return = pConfig->transparentBlue;
return Success;
case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
*value_return = pConfig->transparentAlpha;
return Success;
case GLX_TRANSPARENT_INDEX_VALUE_EXT:
*value_return = pConfig->transparentIndex;
return Success;
case GLX_X_VISUAL_TYPE_EXT:
switch(pConfig->class) {
case TrueColor:
*value_return = GLX_TRUE_COLOR_EXT; break;
case DirectColor:
*value_return = GLX_DIRECT_COLOR_EXT; break;
case PseudoColor:
*value_return = GLX_PSEUDO_COLOR_EXT; break;
case StaticColor:
*value_return = GLX_STATIC_COLOR_EXT; break;
case GrayScale:
*value_return = GLX_GRAY_SCALE_EXT; break;
case StaticGray:
*value_return = GLX_STATIC_GRAY_EXT; break;
}
return Success;
case GLX_VISUAL_CAVEAT_EXT:
*value_return = pConfig->visualRating;
return Success;
default:
return GLX_BAD_ATTRIBUTE;
}
}
}
/*
** If we can't find the config for this visual, this visual is not
** supported by the OpenGL implementation on the server.
*/
if (attribute == GLX_USE_GL) {
*value_return = GL_FALSE;
return Success;
}
return GLX_BAD_VISUAL;
}
/************************************************************************/
/*
** Penalize for more auxiliary buffers than requested
*/
static int AuxScore(int minAux, int aux)
{
return minAux - aux;
}
/*
** If color is desired, give increasing score for amount available.
** Scale this score by a multiplier to make color differences more
** important than other differences. Otherwise give decreasing score for
** amount available.
*/
static int ColorScore(int minColor, int color)
{
if (minColor)
return 4 * (color - minColor);
else
return -color;
}
/*
** If accum buffer is desired, give increasing score for amount
** available. Otherwise give decreasing score for amount available.
*/
static int AccumScore(int minAccum, int accum)
{
if (minAccum)
return accum - minAccum;
else
return -accum;
}
/*
** Penalize for indexes larger than requested
*/
static int IndexScore(int minIndex, int ix)
{
return minIndex - ix;
}
/*
** If depth buffer is desired, give increasing score for amount
** available. Scale this score by a multiplier to make depth differences
** more important than other non-color differences. Otherwise give
** decreasing score for amount available.
*/
static int DepthScore(int minDepth, int depth)
{
if (minDepth)
return 2 * (depth - minDepth);
else
return -depth;
}
/*
** Penalize for stencil buffer larger than requested
*/
static int StencilScore(int minStencil, int stencil)
{
return minStencil - stencil;
}
/* "Logical" xor - like && or ||; would be ^^ */
#define __GLX_XOR(a,b) (((a) && !(b)) || (!(a) && (b)))
/* Fetch a configuration value */
#define __GLX_GCONF(attrib) \
if (GLX_PREFIX(glXGetConfig)(dpy, thisVis, attrib, &val)) { \
XFree((char *)visualList); \
return NULL; \
}
/*
** Return the visual that best matches the template. Return None if no
** visual matches the template.
*/
XVisualInfo *GLX_PREFIX(glXChooseVisual)(Display *dpy, int screen, int *attribList)
{
XVisualInfo visualTemplate;
XVisualInfo *visualList;
XVisualInfo *thisVis;
int count, i, maxscore = 0, maxi, score, val, thisVisRating, maxRating = 0;
/*
** Declare and initialize template variables
*/
int bufferSize = 0;
int level = 0;
int rgba = 0;
int doublebuffer = 0;
int stereo = 0;
int auxBuffers = 0;
int redSize = 0;
int greenSize = 0;
int blueSize = 0;
int alphaSize = 0;
int depthSize = 0;
int stencilSize = 0;
int accumRedSize = 0;
int accumGreenSize = 0;
int accumBlueSize = 0;
int accumAlphaSize = 0;
/* for visual_info extension */
int visualType = 0;
int visualTypeValue = 0;
int transparentPixel = 0;
int transparentPixelValue = GLX_NONE_EXT;
int transparentIndex = 0;
int transparentIndexValue = 0;
int transparentRed = 0;
int transparentRedValue = 0;
int transparentGreen = 0;
int transparentGreenValue = 0;
int transparentBlue = 0;
int transparentBlueValue = 0;
int transparentAlpha = 0;
int transparentAlphaValue = 0;
/* for visual_rating extension */
int visualRating = 0;
int visualRatingValue = GLX_NONE_EXT;
/*
** Get a list of all visuals, return if list is empty
*/
visualTemplate.screen = screen;
visualList = XGetVisualInfo(dpy,VisualScreenMask,&visualTemplate,&count);
if (visualList == NULL)
return None;
/*
** Build a template from the defaults and the attribute list
** Free visual list and return if an unexpected token is encountered
*/
while (*attribList != None) {
switch (*attribList++) {
case GLX_USE_GL:
break;
case GLX_BUFFER_SIZE:
bufferSize = *attribList++;
break;
case GLX_LEVEL:
level = *attribList++;
break;
case GLX_RGBA:
rgba = 1;
break;
case GLX_DOUBLEBUFFER:
doublebuffer = 1;
break;
case GLX_STEREO:
stereo = 1;
break;
case GLX_AUX_BUFFERS:
auxBuffers = *attribList++;
break;
case GLX_RED_SIZE:
redSize = *attribList++;
break;
case GLX_GREEN_SIZE:
greenSize = *attribList++;
break;
case GLX_BLUE_SIZE:
blueSize = *attribList++;
break;
case GLX_ALPHA_SIZE:
alphaSize = *attribList++;
break;
case GLX_DEPTH_SIZE:
depthSize = *attribList++;
break;
case GLX_STENCIL_SIZE:
stencilSize = *attribList++;
break;
case GLX_ACCUM_RED_SIZE:
accumRedSize = *attribList++;
break;
case GLX_ACCUM_GREEN_SIZE:
accumGreenSize = *attribList++;
break;
case GLX_ACCUM_BLUE_SIZE:
accumBlueSize = *attribList++;
break;
case GLX_ACCUM_ALPHA_SIZE:
accumAlphaSize = *attribList++;
break;
case GLX_X_VISUAL_TYPE_EXT:
visualType = 1;
visualTypeValue = *attribList++;
break;
case GLX_TRANSPARENT_TYPE_EXT:
transparentPixel = 1;
transparentPixelValue = *attribList++;
break;
case GLX_TRANSPARENT_INDEX_VALUE_EXT:
transparentIndex= 1;
transparentIndexValue = *attribList++;
break;
case GLX_TRANSPARENT_RED_VALUE_EXT:
transparentRed = 1;
transparentRedValue = *attribList++;
break;
case GLX_TRANSPARENT_GREEN_VALUE_EXT:
transparentGreen = 1;
transparentGreenValue = *attribList++;
break;
case GLX_TRANSPARENT_BLUE_VALUE_EXT:
transparentBlue = 1;
transparentBlueValue = *attribList++;
break;
case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
transparentAlpha = 1;
transparentAlphaValue = *attribList++;
break;
case GLX_VISUAL_CAVEAT_EXT:
visualRating = 1;
visualRatingValue = *attribList++;
break;
default:
XFree((char *)visualList);
return None;
}
}
/*
** Eliminate visuals that don't meet minimum requirements
** Compute a score for those that do
** Remember which visual, if any, got the highest score
*/
maxi = -1;
for (i = 0; i < count; i++) {
score = 0;
thisVis = &visualList[i]; /* NOTE: used by __GLX_GCONF */
if (thisVis->class == TrueColor || thisVis->class == PseudoColor) {
/* Bump score by one for TrueColor and PseudoColor visuals. */
score++;
}
__GLX_GCONF(GLX_USE_GL);
if (! val)
continue;
__GLX_GCONF(GLX_LEVEL);
if (level != val)
continue;
__GLX_GCONF(GLX_RGBA);
if (__GLX_XOR(rgba, val))
continue;
__GLX_GCONF(GLX_DOUBLEBUFFER);
if (__GLX_XOR(doublebuffer, val))
continue;
__GLX_GCONF(GLX_STEREO);
if (__GLX_XOR(stereo, val))
continue;
__GLX_GCONF(GLX_AUX_BUFFERS);
if (auxBuffers > val)
continue;
else
score += AuxScore(auxBuffers, val);
if (transparentPixel) {
if (transparentPixelValue != val)
continue;
if (transparentPixelValue == GLX_TRANSPARENT_TYPE_EXT) {
if (rgba) {
__GLX_GCONF(GLX_TRANSPARENT_RGB_EXT);
if (transparentRed) {
__GLX_GCONF(GLX_TRANSPARENT_RED_VALUE_EXT);
if (transparentRedValue != val)
continue;
}
if (transparentGreen) {
__GLX_GCONF(GLX_TRANSPARENT_GREEN_VALUE_EXT);
if (transparentGreenValue != val)
continue;
}
if (transparentBlue) {
__GLX_GCONF(GLX_TRANSPARENT_BLUE_VALUE_EXT);
if (transparentBlueValue != val)
continue;
}
/* Transparent Alpha ignored for now */
} else {
__GLX_GCONF(GLX_TRANSPARENT_INDEX_EXT);
if (transparentIndex) {
__GLX_GCONF(GLX_TRANSPARENT_INDEX_VALUE_EXT);
if (transparentIndexValue != val)
continue;
}
}
}
}
if (visualType) {
__GLX_GCONF(GLX_X_VISUAL_TYPE_EXT);
if (visualTypeValue != val)
continue;
} else if (rgba) {
/* If the extension isn't specified then insure that rgba
** and ci return the usual visual types.
*/
if (!(thisVis->class == TrueColor || thisVis->class == DirectColor))
continue;
} else {
if (!(thisVis->class == PseudoColor
|| thisVis->class == StaticColor))
continue;
}
__GLX_GCONF(GLX_VISUAL_CAVEAT_EXT);
/**
** Unrated visuals are given rating GLX_NONE.
*/
thisVisRating = val ? val : GLX_NONE_EXT;
if (visualRating && (visualRatingValue != val))
continue;
if (rgba) {
__GLX_GCONF(GLX_RED_SIZE);
if (redSize > val)
continue;
else
score += ColorScore(redSize,val);
__GLX_GCONF(GLX_GREEN_SIZE);
if (greenSize > val)
continue;
else
score += ColorScore(greenSize, val);
__GLX_GCONF(GLX_BLUE_SIZE);
if (blueSize > val)
continue;
else
score += ColorScore(blueSize, val);
__GLX_GCONF(GLX_ALPHA_SIZE);
if (alphaSize > val)
continue;
else
score += ColorScore(alphaSize, val);
__GLX_GCONF(GLX_ACCUM_RED_SIZE);
if (accumRedSize > val)
continue;
else
score += AccumScore(accumRedSize, val);
__GLX_GCONF(GLX_ACCUM_GREEN_SIZE);
if (accumGreenSize > val)
continue;
else
score += AccumScore(accumGreenSize, val);
__GLX_GCONF(GLX_ACCUM_BLUE_SIZE);
if (accumBlueSize > val)
continue;
else
score += AccumScore(accumBlueSize, val);
__GLX_GCONF(GLX_ACCUM_ALPHA_SIZE);
if (accumAlphaSize > val)
continue;
else
score += AccumScore(accumAlphaSize, val);
} else {
__GLX_GCONF(GLX_BUFFER_SIZE);
if (bufferSize > val)
continue;
else
score += IndexScore(bufferSize, val);
}
__GLX_GCONF(GLX_DEPTH_SIZE);
if (depthSize > val)
continue;
else
score += DepthScore(depthSize, val);
__GLX_GCONF(GLX_STENCIL_SIZE);
if (stencilSize > val)
continue;
else
score += StencilScore(stencilSize, val);
/*
** The visual_rating extension indicates that a NONE visual
** is always returned in preference to a SLOW one.
** Note that enum values are in increasing order (NONE < SLOW).
*/
if (maxi < 0 || maxRating > thisVisRating) {
maxi = i;
maxscore = score;
maxRating = thisVisRating;
} else {
if (score > maxscore) {
maxi = i;
maxscore = score;
}
}
}
/*
** If no visual is acceptable, return None
** Otherwise, create an XVisualInfo list with just the selected X visual
** and return this after freeing the original list
*/
if (maxi < 0) {
XFree((char *)visualList);
return None;
} else {
visualTemplate.visualid = visualList[maxi].visualid;
XFree((char *)visualList);
visualList = XGetVisualInfo(dpy,VisualScreenMask|VisualIDMask,&visualTemplate,&count);
return visualList;
}
}
/*
** Query the Server GLX string and cache it in the display private.
** This routine will allocate the necessay space for the string.
*/
static char *QueryServerString( Display *dpy, int opcode,
int screen, int name )
{
xGLXQueryServerStringReq *req;
xGLXQueryServerStringReply reply;
int length, numbytes, slop;
char *buf;
/* Send the glXQueryServerString request */
LockDisplay(dpy);
GetReq(GLXQueryServerString,req);
req->reqType = opcode;
req->glxCode = X_GLXQueryServerString;
req->screen = screen;
req->name = name;
_XReply(dpy, (xReply*) &reply, 0, False);
length = reply.length;
numbytes = reply.n;
slop = numbytes * __GLX_SIZE_INT8 & 3;
buf = (char *)Xmalloc(numbytes);
if (!buf) {
/* Throw data on the floor */
_XEatData(dpy, length);
} else {
_XRead(dpy, (char *)buf, numbytes);
if (slop) _XEatData(dpy,4-slop);
}
UnlockDisplay(dpy);
SyncHandle();
return buf;
}
#define SEPARATOR " "
static char *combine_strings( const char *cext_string, const char *sext_string )
{
int clen, slen;
char *combo_string, *token, *s1;
const char *s2, *end;
/*
** String can't be longer than min(cstring, sstring)
** pull tokens out of shortest string
** include space in combo_string for final separator and null terminator
*/
if ( (clen = strlen( cext_string)) > (slen = strlen( sext_string)) ) {
combo_string = (char *) Xmalloc( slen + 2 );
s1 = (char *) malloc( slen + 2 ); strcpy( s1, sext_string );
s2 = cext_string;
} else {
combo_string = (char *) Xmalloc( clen + 2 );
s1 = (char *) Xmalloc( clen + 2 ); strcpy( s1, cext_string);
s2 = sext_string;
}
if (!combo_string || !s1) {
if (combo_string) Xfree(combo_string);
if (s1) Xfree(s1);
return NULL;
}
combo_string[0] = '\0';
/* Get first extension token */
token = strtok( s1, SEPARATOR);
while ( token != NULL ) {
/*
** if token in second string then save it
** beware of extension names which are prefixes of other extension names
*/
const char *p = s2;
end = p + strlen(p);
while (p < end) {
int n = strcspn(p, SEPARATOR);
if ((strlen(token) == n) && (strncmp(token, p, n) == 0)) {
combo_string = strcat( combo_string, token);
combo_string = strcat( combo_string, SEPARATOR);
}
p += (n + 1);
}
/* Get next extension token */
token = strtok( NULL, SEPARATOR);
}
Xfree(s1);
return combo_string;
}
const char *GLX_PREFIX(glXQueryExtensionsString)( Display *dpy, int screen )
{
__GLXvisualConfig *pConfig;
__GLXscreenConfigs *psc;
__GLXdisplayPrivate *priv;
/* Initialize the extension, if needed . This has the added value
of initializing/allocating the display private */
priv = __glXInitialize(dpy);
if (!priv) {
return NULL;
}
/* Check screen number to see if its valid */
if ((screen < 0) || (screen >= ScreenCount(dpy))) {
return NULL;
}
/* Check to see if the GL is supported on this screen */
psc = &priv->screenConfigs[screen];
pConfig = psc->configs;
if (!pConfig) {
/* No support for GL on this screen regardless of visual */
return NULL;
}
if (!psc->effectiveGLXexts) {
if (!psc->serverGLXexts) {
psc->serverGLXexts = QueryServerString(dpy, priv->majorOpcode,
screen, GLX_EXTENSIONS);
}
psc->effectiveGLXexts = combine_strings(__glXGLXClientExtensions,
psc->serverGLXexts);
}
return psc->effectiveGLXexts;
}
const char *GLX_PREFIX(glXGetClientString)( Display *dpy, int name )
{
switch(name) {
case GLX_VENDOR:
return (__glXGLXClientVendorName);
case GLX_VERSION:
return (__glXGLXClientVersion);
case GLX_EXTENSIONS:
return (__glXGLXClientExtensions);
default:
return NULL;
}
}
const char *GLX_PREFIX(glXQueryServerString)( Display *dpy, int screen, int name )
{
__GLXvisualConfig *pConfig;
__GLXscreenConfigs *psc;
__GLXdisplayPrivate *priv;
/* Initialize the extension, if needed . This has the added value
of initializing/allocating the display private */
priv = __glXInitialize(dpy);
if (!priv) {
/* No extension */
return NULL;
}
/* Check screen number to see if its valid */
if ((screen < 0) || (screen >= ScreenCount(dpy))) {
return NULL;
}
/* Check to see if the GL is supported on this screen */
psc = &priv->screenConfigs[screen];
pConfig = psc->configs;
if (!pConfig) {
/* No support for GL on this screen regardless of visual */
return NULL;
}
switch(name) {
case GLX_VENDOR:
if (!priv->serverGLXvendor) {
priv->serverGLXvendor =
QueryServerString(dpy, priv->majorOpcode,
screen, GLX_VENDOR);
}
return(priv->serverGLXvendor);
case GLX_VERSION:
if (!priv->serverGLXversion) {
priv->serverGLXversion =
QueryServerString(dpy, priv->majorOpcode,
screen, GLX_VERSION);
}
return(priv->serverGLXversion);
case GLX_EXTENSIONS:
if (!psc->serverGLXexts) {
psc->serverGLXexts =
QueryServerString(dpy, priv->majorOpcode,
screen, GLX_EXTENSIONS);
}
return(psc->serverGLXexts);
default:
return NULL;
}
}
void __glXClientInfo ( Display *dpy, int opcode )
{
xGLXClientInfoReq *req;
int size;
/* Send the glXClientInfo request */
LockDisplay(dpy);
GetReq(GLXClientInfo,req);
req->reqType = opcode;
req->glxCode = X_GLXClientInfo;
req->major = GLX_MAJOR_VERSION;
req->minor = GLX_MINOR_VERSION;
size = strlen(__glXGLClientExtensions) + 1;
req->length += (size + 3) >> 2;
req->numbytes = size;
Data(dpy, __glXGLClientExtensions, size);
UnlockDisplay(dpy);
SyncHandle();
}
/************************************************************************/
/*
** EXT_import_context entry points
*/
/************************************************************************/
Display *glXGetCurrentDisplay(void)
{
GLXContext gc = __glXGetCurrentContext();
if (NULL == gc) return NULL;
return gc->currentDpy;
}
Display *glXGetCurrentDisplayEXT(void)
{
GLXContext gc = __glXGetCurrentContext();
if (NULL == gc) return NULL;
return gc->currentDpy;
}
static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
{
xGLXVendorPrivateReq *vpreq;
xGLXQueryContextInfoEXTReq *req;
xGLXQueryContextInfoEXTReply reply;
CARD8 opcode;
GLuint numValues;
if (ctx == NULL) {
return GLX_BAD_CONTEXT;
}
opcode = __glXSetupForCommand(dpy);
if (!opcode) {
return 0;
}
/* Send the glXQueryContextInfoEXT request */
LockDisplay(dpy);
GetReqExtra(GLXVendorPrivate,
sz_xGLXQueryContextInfoEXTReq-sz_xGLXVendorPrivateReq,vpreq);
req = (xGLXQueryContextInfoEXTReq *)vpreq;
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_QueryContextInfoEXT;
req->context = (unsigned int)(ctx->xid);
_XReply(dpy, (xReply*) &reply, 0, False);
UnlockDisplay(dpy);
numValues = reply.n;
if (numValues == 0) return Success;
if (numValues > __GLX_MAX_CONTEXT_PROPS) return 0;
{
int *propList, *pProp;
int nPropListBytes;
int i;
nPropListBytes = numValues << 3;
propList = (int *) Xmalloc(nPropListBytes);
if (NULL == propList) {
return 0;
}
_XRead(dpy, (char *)propList, nPropListBytes);
pProp = propList;
for (i=0; i < numValues; i++) {
switch (*pProp++) {
case GLX_SHARE_CONTEXT_EXT:
ctx->share_xid = *pProp++;
break;
case GLX_VISUAL_ID_EXT:
ctx->vid = *pProp++;
break;
case GLX_SCREEN_EXT:
ctx->screen = *pProp++;
break;
default:
pProp++;
continue;
}
}
Xfree((char *)propList);
}
SyncHandle();
return Success;
}
int GLX_PREFIX(glXQueryContextInfoEXT)(Display *dpy, GLXContext ctx,
int attribute, int *value)
{
int retVal;
/* get the information from the server if we don't have it already */
if (!ctx->isDirect && (ctx->vid == None)) {
retVal = __glXQueryContextInfo(dpy, ctx);
if (Success != retVal) return retVal;
}
switch (attribute) {
case GLX_SHARE_CONTEXT_EXT:
*value = (int)(ctx->share_xid);
break;
case GLX_VISUAL_ID_EXT:
*value = (int)(ctx->vid);
break;
case GLX_SCREEN_EXT:
*value = (int)(ctx->screen);
break;
default:
return GLX_BAD_ATTRIBUTE;
}
return Success;
}
GLXContextID glXGetContextIDEXT(const GLXContext ctx)
{
return ctx->xid;
}
GLXContext GLX_PREFIX(glXImportContextEXT)(Display *dpy, GLXContextID contextID)
{
GLXContext ctx;
if (contextID == None) {
return NULL;
}
if (__glXIsDirect(dpy, contextID)) {
return NULL;
}
ctx = CreateContext(dpy, NULL, NULL, GL_FALSE, contextID);
if (NULL != ctx) {
if (Success != __glXQueryContextInfo(dpy, ctx)) {
return NULL;
}
}
return ctx;
}
void GLX_PREFIX(glXFreeContextEXT)(Display *dpy, GLXContext ctx)
{
DestroyContext(dpy, ctx);
}
/*
* GLX 1.3 functions - these are just stubs for now!
*/
GLXFBConfig *GLX_PREFIX(glXChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems)
{
(void) dpy;
(void) screen;
(void) attribList;
(void) nitems;
return 0;
}
GLXContext GLX_PREFIX(glXCreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
{
(void) dpy;
(void) config;
(void) renderType;
(void) shareList;
(void) direct;
return 0;
}
GLXPbuffer GLX_PREFIX(glXCreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList)
{
(void) dpy;
(void) config;
(void) attribList;
return 0;
}
GLXPixmap GLX_PREFIX(glXCreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
{
(void) dpy;
(void) config;
(void) pixmap;
(void) attribList;
return 0;
}
GLXWindow GLX_PREFIX(glXCreateWindow)(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
{
(void) dpy;
(void) config;
(void) win;
(void) attribList;
return 0;
}
void GLX_PREFIX(glXDestroyPbuffer)(Display *dpy, GLXPbuffer pbuf)
{
(void) dpy;
(void) pbuf;
}
void GLX_PREFIX(glXDestroyPixmap)(Display *dpy, GLXPixmap pixmap)
{
(void) dpy;
(void) pixmap;
}
void GLX_PREFIX(glXDestroyWindow)(Display *dpy, GLXWindow window)
{
(void) dpy;
(void) window;
}
GLXDrawable glXGetCurrentReadDrawable(void)
{
GLXContext gc = __glXGetCurrentContext();
return gc->currentDrawable;
}
GLXFBConfig *GLX_PREFIX(glXGetFBConfigs)(Display *dpy, int screen, int *nelements)
{
(void) dpy;
(void) screen;
(void) nelements;
return 0;
}
int GLX_PREFIX(glXGetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value)
{
(void) dpy;
(void) config;
(void) attribute;
(void) value;
return 0;
}
void GLX_PREFIX(glXGetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigned long *mask)
{
(void) dpy;
(void) drawable;
(void) mask;
}
XVisualInfo *GLX_PREFIX(glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config)
{
(void) dpy;
(void) config;
return 0;
}
Bool GLX_PREFIX(glXMakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
{
(void) dpy;
(void) draw;
(void) read;
(void) ctx;
return 0;
}
int GLX_PREFIX(glXQueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value)
{
(void) dpy;
(void) ctx;
(void) attribute;
(void) value;
return 0;
}
void GLX_PREFIX(glXQueryDrawable)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
{
(void) dpy;
(void) draw;
(void) attribute;
(void) value;
}
void GLX_PREFIX(glXSelectEvent)(Display *dpy, GLXDrawable drawable, unsigned long mask)
{
(void) dpy;
(void) drawable;
(void) mask;
}
/*
** GLX_SGIS_make_current_read
*/
Bool GLX_PREFIX(glXMakeCurrentReadSGI)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
{
(void) dpy;
(void) draw;
(void) read;
(void) ctx;
return False;
}
GLXDrawable glXGetCurrentReadDrawableSGI(void)
{
return 0;
}
/*
** GLX_SGI_swap_control
*/
int GLX_PREFIX(glXSwapIntervalSGI)(int interval)
{
(void) interval;
return 0;
}
/*
** GLX_SGI_video_sync
*/
int GLX_PREFIX(glXGetVideoSyncSGI)(unsigned int *count)
{
(void) count;
return 0;
}
int GLX_PREFIX(glXWaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count)
{
(void) divisor;
(void) remainder;
(void) count;
return 0;
}
/*
** GLX_SGIS_video_source
*/
#if defined(_VL_H)
GLXVideoSourceSGIX GLX_PREFIX(glXCreateGLXVideoSourceSGIX)(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
{
(void) dpy;
(void) screen;
(void) server;
(void) path;
(void) nodeClass;
(void) drainNode;
return 0;
}
void GLX_PREFIX(glXDestroyGLXVideoSourceSGIX)(Display *dpy, GLXVideoSourceSGIX src)
{
(void) dpy;
(void) src;
}
#endif
/*
** GLX_SGIX_fbconfig
*/
int GLX_PREFIX(glXGetFBConfigAttribSGIX)(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
{
(void) dpy;
(void) config;
(void) attribute;
(void) value;
return 0;
}
GLXFBConfigSGIX * GLX_PREFIX(glXChooseFBConfigSGIX)(Display *dpy, int screen, int *attrib_list, int *nelements)
{
(void) dpy;
(void) screen;
(void) attrib_list;
(void) nelements;
return 0;
}
GLXPixmap GLX_PREFIX(glXCreateGLXPixmapWithConfigSGIX)(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
{
(void) dpy;
(void) config;
(void) pixmap;
return 0;
}
GLXContext GLX_PREFIX(glXCreateContextWithConfigSGIX)(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
{
(void) dpy;
(void) config;
(void) render_type;
(void) share_list;
(void) direct;
return 0;
}
XVisualInfo * GLX_PREFIX(glXGetVisualFromFBConfigSGIX)(Display *dpy, GLXFBConfigSGIX config)
{
(void) dpy;
(void) config;
return NULL;
}
GLXFBConfigSGIX GLX_PREFIX(glXGetFBConfigFromVisualSGIX)(Display *dpy, XVisualInfo *vis)
{
(void) dpy;
(void) vis;
return 0;
}
/*
** GLX_SGIX_pbuffer
*/
GLXPbufferSGIX GLX_PREFIX(glXCreateGLXPbufferSGIX)(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
{
(void) dpy;
(void) config;
(void) width;
(void) height;
(void) attrib_list;
return 0;
}
void GLX_PREFIX(glXDestroyGLXPbufferSGIX)(Display *dpy, GLXPbufferSGIX pbuf)
{
(void) dpy;
(void) pbuf;
}
int GLX_PREFIX(glXQueryGLXPbufferSGIX)(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
{
(void) dpy;
(void) pbuf;
(void) attribute;
(void) value;
return 0;
}
void GLX_PREFIX(glXSelectEventSGIX)(Display *dpy, GLXDrawable drawable, unsigned long mask)
{
(void) dpy;
(void) drawable;
(void) mask;
}
void GLX_PREFIX(glXGetSelectedEventSGIX)(Display *dpy, GLXDrawable drawable, unsigned long *mask)
{
(void) dpy;
(void) drawable;
(void) mask;
}
/*
** GLX_SGI_cushion
*/
void GLX_PREFIX(glXCushionSGI)(Display *dpy, Window win, float cushion)
{
(void) dpy;
(void) win;
(void) cushion;
}
/*
** GLX_SGIX_video_resize
*/
int GLX_PREFIX(glXBindChannelToWindowSGIX)(Display *dpy, int screen, int channel , Window window)
{
(void) dpy;
(void) screen;
(void) channel;
(void) window;
return 0;
}
int GLX_PREFIX(glXChannelRectSGIX)(Display *dpy, int screen, int channel, int x, int y, int w, int h)
{
(void) dpy;
(void) screen;
(void) channel;
(void) x;
(void) y;
(void) w;
(void) h;
return 0;
}
int GLX_PREFIX(glXQueryChannelRectSGIX)(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
{
(void) dpy;
(void) screen;
(void) channel;
(void) x;
(void) y;
(void) w;
(void) h;
return 0;
}
int GLX_PREFIX(glXQueryChannelDeltasSGIX)(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
{
(void) dpy;
(void) screen;
(void) channel;
(void) dx;
(void) dy;
(void) dw;
(void) dh;
return 0;
}
int GLX_PREFIX(glXChannelRectSyncSGIX)(Display *dpy, int screen, int channel, GLenum synctype)
{
(void) dpy;
(void) screen;
(void) channel;
(void) synctype;
return 0;
}
#if defined(_DM_BUFFER_H_)
Bool GLX_PREFIX(glXAssociateDMPbufferSGIX)(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
{
(void) dpy;
(void) pbuffer;
(void) params;
(void) dmbuffer;
return False;
}
#endif
/*
** GLX_SGIX_swap_group
*/
void GLX_PREFIX(glXJoinSwapGroupSGIX)(Display *dpy, GLXDrawable drawable, GLXDrawable member)
{
(void) dpy;
(void) drawable;
(void) member;
}
/*
** GLX_SGIX_swap_barrier
*/
void GLX_PREFIX(glXBindSwapBarrierSGIX)(Display *dpy, GLXDrawable drawable, int barrier)
{
(void) dpy;
(void) drawable;
(void) barrier;
}
Bool GLX_PREFIX(glXQueryMaxSwapBarriersSGIX)(Display *dpy, int screen, int *max)
{
(void) dpy;
(void) screen;
(void) max;
return False;
}
/*
** GLX_SUN_get_transparent_index
*/
Status GLX_PREFIX(glXGetTransparentIndexSUN)(Display *dpy, Window overlay, Window underlay, long *pTransparent)
{
(void) dpy;
(void) overlay;
(void) underlay;
(void) pTransparent;
return 0;
}
/*
** Mesa extension stubs. These will help reduce portability problems.
*/
Bool GLX_PREFIX(glXReleaseBuffersMESA)( Display *dpy, GLXDrawable d )
{
(void) dpy;
(void) d;
return False;
}
GLXPixmap GLX_PREFIX(glXCreateGLXPixmapMESA)( Display *dpy,
XVisualInfo *visual,
Pixmap pixmap, Colormap cmap )
{
(void) dpy;
(void) visual;
(void) pixmap;
(void) cmap;
return 0;
}
void GLX_PREFIX(glXCopySubBufferMESA)( Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height )
{
(void) dpy;
(void) drawable;
(void) x;
(void) y;
(void) width;
(void) height;
}
Bool GLX_PREFIX(glXSet3DfxModeMESA)( int mode )
{
(void) mode;
return GL_FALSE;
}
/*
** glXGetProcAddress support
*/
struct name_address_pair {
const char *Name;
GLvoid *Address;
};
static struct name_address_pair GLX_functions[] = {
/*** GLX_VERSION_1_0 ***/
{ "glXChooseVisual", (GLvoid *) glXChooseVisual },
{ "glXCopyContext", (GLvoid *) glXCopyContext },
{ "glXCreateContext", (GLvoid *) glXCreateContext },
{ "glXCreateGLXPixmap", (GLvoid *) glXCreateGLXPixmap },
{ "glXDestroyContext", (GLvoid *) glXDestroyContext },
{ "glXDestroyGLXPixmap", (GLvoid *) glXDestroyGLXPixmap },
{ "glXGetConfig", (GLvoid *) glXGetConfig },
{ "glXGetCurrentContext", (GLvoid *) glXGetCurrentContext },
{ "glXGetCurrentDrawable", (GLvoid *) glXGetCurrentDrawable },
{ "glXIsDirect", (GLvoid *) glXIsDirect },
{ "glXMakeCurrent", (GLvoid *) glXMakeCurrent },
{ "glXQueryExtension", (GLvoid *) glXQueryExtension },
{ "glXQueryVersion", (GLvoid *) glXQueryVersion },
{ "glXSwapBuffers", (GLvoid *) glXSwapBuffers },
{ "glXUseXFont", (GLvoid *) glXUseXFont },
{ "glXWaitGL", (GLvoid *) glXWaitGL },
{ "glXWaitX", (GLvoid *) glXWaitX },
/*** GLX_VERSION_1_1 ***/
{ "glXGetClientString", (GLvoid *) glXGetClientString },
{ "glXQueryExtensionsString", (GLvoid *) glXQueryExtensionsString },
{ "glXQueryServerString", (GLvoid *) glXQueryServerString },
/*** GLX_VERSION_1_2 ***/
{ "glXGetCurrentDisplay", (GLvoid *) glXGetCurrentDisplay },
/*** GLX_VERSION_1_3 ***/
{ "glXChooseFBConfig", (GLvoid *) glXChooseFBConfig },
{ "glXCreateNewContext", (GLvoid *) glXCreateNewContext },
{ "glXCreatePbuffer", (GLvoid *) glXCreatePbuffer },
{ "glXCreatePixmap", (GLvoid *) glXCreatePixmap },
{ "glXCreateWindow", (GLvoid *) glXCreateWindow },
{ "glXDestroyPbuffer", (GLvoid *) glXDestroyPbuffer },
{ "glXDestroyPixmap", (GLvoid *) glXDestroyPixmap },
{ "glXDestroyWindow", (GLvoid *) glXDestroyWindow },
{ "glXGetCurrentReadDrawable", (GLvoid *) glXGetCurrentReadDrawable },
{ "glXGetFBConfigAttrib", (GLvoid *) glXGetFBConfigAttrib },
{ "glXGetFBConfigs", (GLvoid *) glXGetFBConfigs },
{ "glXGetSelectedEvent", (GLvoid *) glXGetSelectedEvent },
{ "glXGetVisualFromFBConfig", (GLvoid *) glXGetVisualFromFBConfig },
{ "glXMakeContextCurrent", (GLvoid *) glXMakeContextCurrent },
{ "glXQueryContext", (GLvoid *) glXQueryContext },
{ "glXQueryDrawable", (GLvoid *) glXQueryDrawable },
{ "glXSelectEvent", (GLvoid *) glXSelectEvent },
/*** GLX_SGI_swap_control ***/
{ "glXSwapIntervalSGI", (GLvoid *) glXSwapIntervalSGI },
/*** GLX_SGI_video_sync ***/
{ "glXGetVideoSyncSGI", (GLvoid *) glXGetVideoSyncSGI },
{ "glXWaitVideoSyncSGI", (GLvoid *) glXWaitVideoSyncSGI },
/*** GLX_SGI_make_current_read ***/
{ "glXMakeCurrentReadSGI", (GLvoid *) glXMakeCurrentReadSGI },
{ "glXGetCurrentReadDrawableSGI", (GLvoid *) glXGetCurrentReadDrawableSGI },
/*** GLX_SGIX_video_source ***/
#if defined(_VL_H)
{ "glXCreateGLXVideoSourceSGIX", (GLvoid *) glXCreateGLXVideoSourceSGIX },
{ "glXDestroyGLXVideoSourceSGIX", (GLvoid *) glXDestroyGLXVideoSourceSGIX },
#endif
/*** GLX_EXT_import_context ***/
{ "glXFreeContextEXT", (GLvoid *) glXFreeContextEXT },
{ "glXGetContextIDEXT", (GLvoid *) glXGetContextIDEXT },
{ "glXGetCurrentDisplayEXT", (GLvoid *) glXGetCurrentDisplayEXT },
{ "glXImportContextEXT", (GLvoid *) glXImportContextEXT },
{ "glXQueryContextInfoEXT", (GLvoid *) glXQueryContextInfoEXT },
/*** GLX_SGIX_fbconfig ***/
{ "glXGetFBConfigAttribSGIX", (GLvoid *) glXGetFBConfigAttribSGIX },
{ "glXChooseFBConfigSGIX", (GLvoid *) glXChooseFBConfigSGIX },
{ "glXCreateGLXPixmapWithConfigSGIX", (GLvoid *) glXCreateGLXPixmapWithConfigSGIX },
{ "glXCreateContextWithConfigSGIX", (GLvoid *) glXCreateContextWithConfigSGIX },
{ "glXGetVisualFromFBConfigSGIX", (GLvoid *) glXGetVisualFromFBConfigSGIX },
{ "glXGetFBConfigFromVisualSGIX", (GLvoid *) glXGetFBConfigFromVisualSGIX },
/*** GLX_SGIX_pbuffer ***/
{ "glXCreateGLXPbufferSGIX", (GLvoid *) glXCreateGLXPbufferSGIX },
{ "glXDestroyGLXPbufferSGIX", (GLvoid *) glXDestroyGLXPbufferSGIX },
{ "glXQueryGLXPbufferSGIX", (GLvoid *) glXQueryGLXPbufferSGIX },
{ "glXSelectEventSGIX", (GLvoid *) glXSelectEventSGIX },
{ "glXGetSelectedEventSGIX", (GLvoid *) glXGetSelectedEventSGIX },
/*** GLX_SGI_cushion ***/
{ "glXCushionSGI", (GLvoid *) glXCushionSGI },
/*** GLX_SGIX_video_resize ***/
{ "glXBindChannelToWindowSGIX", (GLvoid *) glXBindChannelToWindowSGIX },
{ "glXChannelRectSGIX", (GLvoid *) glXChannelRectSGIX },
{ "glXQueryChannelRectSGIX", (GLvoid *) glXQueryChannelRectSGIX },
{ "glXQueryChannelDeltasSGIX", (GLvoid *) glXQueryChannelDeltasSGIX },
{ "glXChannelRectSyncSGIX", (GLvoid *) glXChannelRectSyncSGIX },
/*** GLX_SGIX_dmbuffer **/
#if defined(_DM_BUFFER_H_)
{ "glXAssociateDMPbufferSGIX", (GLvoid *) glXAssociateDMPbufferSGIX },
#endif
/*** GLX_SGIX_swap_group ***/
{ "glXJoinSwapGroupSGIX", (GLvoid *) glXJoinSwapGroupSGIX },
/*** GLX_SGIX_swap_barrier ***/
{ "glXBindSwapBarrierSGIX", (GLvoid *) glXBindSwapBarrierSGIX },
{ "glXQueryMaxSwapBarriersSGIX", (GLvoid *) glXQueryMaxSwapBarriersSGIX },
/*** GLX_SUN_get_transparent_index ***/
{ "glXGetTransparentIndexSUN", (GLvoid *) glXGetTransparentIndexSUN },
/*** GLX_MESA_copy_sub_buffer ***/
{ "glXCopySubBufferMESA", (GLvoid *) glXCopySubBufferMESA },
/*** GLX_MESA_pixmap_colormap ***/
{ "glXCreateGLXPixmapMESA", (GLvoid *) glXCreateGLXPixmapMESA },
/*** GLX_MESA_release_buffers ***/
{ "glXReleaseBuffersMESA", (GLvoid *) glXReleaseBuffersMESA },
/*** GLX_MESA_set_3dfx_mode ***/
{ "glXSet3DfxModeMESA", (GLvoid *) glXSet3DfxModeMESA },
/*** GLX_ARB_get_proc_address ***/
{ "glXGetProcAddressARB", (GLvoid *) glXGetProcAddressARB },
{ NULL, NULL } /* end of list */
};
static const GLvoid *
get_glx_proc_address(const char *funcName)
{
GLuint i;
for (i = 0; GLX_functions[i].Name; i++) {
if (strcmp(GLX_functions[i].Name, funcName) == 0)
return GLX_functions[i].Address;
}
return NULL;
}
#ifndef GLX_BUILT_IN_XMESA
void (*glXGetProcAddressARB(const GLubyte *procName))()
{
typedef void (*gl_function)();
gl_function f;
#if defined(GLX_DIRECT_RENDERING)
__glXRegisterExtensions();
#endif
f = (gl_function) get_glx_proc_address((const char *) procName);
if (f) {
return f;
}
f = (gl_function) _glapi_get_proc_address((const char *) procName);
return f;
}
#endif
|