File: glext_8c_source.html

package info (click to toggle)
allegro4.4 2%3A4.4.2-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 19,920 kB
  • ctags: 39,951
  • sloc: ansic: 164,225; asm: 17,620; cpp: 3,848; objc: 1,687; sh: 1,131; python: 676; pascal: 179; makefile: 48; perl: 29; lisp: 1
file content (682 lines) | stat: -rw-r--r-- 57,183 bytes parent folder | download | duplicates (4)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>AllegroGL: glext.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="alleggl.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">AllegroGL&#160;<span id="projectnumber">0.4.4</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('glext_8c.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>glext.c</h1>  </div>
</div>
<div class="contents">
<a href="glext_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* This code is (C) AllegroGL contributors, and double licensed under</span>
<a name="l00002"></a>00002 <span class="comment"> * the GPL and zlib licenses. See gpl.txt or zlib.txt for details.</span>
<a name="l00003"></a>00003 <span class="comment"> */</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;alleggl.h&quot;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#include &quot;allglint.h&quot;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#include &lt;OpenGL/glu.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#else</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#include &lt;GL/glu.h&gt;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#endif</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;allegro/internal/aintern.h&gt;</span>
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="comment">/* GL extension Structure. Holds the extension pointers for a single context */</span>
<a name="l00021"></a>00021 <span class="preprocessor">#define AGL_API(type, name, args) AGL_##name##_t name;</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>AGL_EXT {
<a name="l00023"></a>00023 <span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_api.h&quot;</span>
<a name="l00024"></a>00024 <span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/wgl_ext_api.h&quot;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/glx_ext_api.h&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#endif</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span>} AGL_EXT;
<a name="l00030"></a>00030 <span class="preprocessor">#undef AGL_API</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#define PREFIX_I                &quot;agl-ext INFO: &quot;</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define PREFIX_W                &quot;agl-ext WARNING: &quot;</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span><span class="preprocessor">#define PREFIX_E                &quot;agl-ext ERROR: &quot;</span>
<a name="l00035"></a>00035 <span class="preprocessor"></span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="comment">/* Current driver info */</span>
<a name="l00038"></a>00038 <span class="keyword">struct </span>allegro_gl_info allegro_gl_info;
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 
<a name="l00055"></a><a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436">00055</a> <span class="keyword">struct </span>AGL_EXTENSION_LIST_GL <a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>;
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 
<a name="l00064"></a>00064 <span class="preprocessor">#ifdef ALLEGRO_UNIX</span>
<a name="l00065"></a>00065 <span class="preprocessor"></span><span class="keyword">struct </span>AGL_EXTENSION_LIST_GLX allegro_gl_extensions_GLX;
<a name="l00066"></a>00066 <span class="preprocessor">#endif</span>
<a name="l00067"></a>00067 <span class="preprocessor"></span>
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 
<a name="l00075"></a>00075 <span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span><span class="keyword">struct </span>AGL_EXTENSION_LIST_WGL allegro_gl_extensions_WGL;
<a name="l00077"></a>00077 <span class="preprocessor">#endif</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 
<a name="l00081"></a>00081 <span class="comment">/* Current context */</span>
<a name="l00082"></a><a class="code" href="group__extensions.html#ga2d6ebb26eec58470e4242b750656268b">00082</a> AGL_EXT *<a class="code" href="group__extensions.html#ga2d6ebb26eec58470e4242b750656268b" title="List of GLX extensions supported by AllegroGL.">agl_extension_table</a> = NULL;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084 
<a name="l00085"></a>00085 <span class="preprocessor">#ifdef ALLEGROGL_GENERIC_DRIVER</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#include &quot;GL/amesa.h&quot;</span>
<a name="l00087"></a>00087 <span class="preprocessor">#endif</span>
<a name="l00088"></a>00088 <span class="preprocessor"></span>
<a name="l00089"></a>00089 
<a name="l00090"></a>00090 <span class="preprocessor">#ifdef ALLEGROGL_HAVE_DYNAMIC_LINK</span>
<a name="l00091"></a>00091 <span class="preprocessor"></span><span class="preprocessor">#include &lt;dlfcn.h&gt;</span>
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 <span class="comment">/* Handle for dynamic library libGL.so */</span>
<a name="l00094"></a>00094 <span class="keyword">static</span> <span class="keywordtype">void</span>* __agl_handle = NULL;
<a name="l00095"></a>00095 <span class="comment">/* Pointer to glXGetProcAddressARB */</span>
<a name="l00096"></a>00096 <span class="keyword">typedef</span> <span class="keywordtype">void</span>* (*GLXGETPROCADDRESSARBPROC) (<span class="keyword">const</span> GLubyte*);
<a name="l00097"></a>00097 <span class="keyword">static</span> GLXGETPROCADDRESSARBPROC aglXGetProcAddress;
<a name="l00098"></a>00098 <span class="preprocessor">#else</span>
<a name="l00099"></a>00099 <span class="preprocessor"></span><span class="comment">/* Tries static linking */</span>
<a name="l00100"></a>00100 <span class="preprocessor">#ifdef ALLEGROGL_GLXGETPROCADDRESSARB</span>
<a name="l00101"></a>00101 <span class="preprocessor"></span><span class="preprocessor">#define aglXGetProcAddress glXGetProcAddressARB</span>
<a name="l00102"></a>00102 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00103"></a>00103 <span class="preprocessor"></span><span class="preprocessor">#define aglXGetProcAddress glXGetProcAddress</span>
<a name="l00104"></a>00104 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00105"></a>00105 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00106"></a>00106 <span class="preprocessor"></span>
<a name="l00107"></a>00107 
<a name="l00108"></a>00108 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span><span class="preprocessor">#undef TRUE</span>
<a name="l00110"></a>00110 <span class="preprocessor"></span><span class="preprocessor">#undef FALSE</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span><span class="preprocessor">#include &lt;Carbon/Carbon.h&gt;</span>
<a name="l00112"></a>00112 <span class="preprocessor">#undef TRUE</span>
<a name="l00113"></a>00113 <span class="preprocessor"></span><span class="preprocessor">#undef FALSE</span>
<a name="l00114"></a>00114 <span class="preprocessor"></span><span class="preprocessor">#define TRUE  -1</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span><span class="preprocessor">#define FALSE 0</span>
<a name="l00116"></a>00116 <span class="preprocessor"></span>
<a name="l00117"></a>00117 <span class="keyword">static</span> CFBundleRef opengl_bundle_ref;
<a name="l00118"></a>00118 <span class="preprocessor">#endif</span>
<a name="l00119"></a>00119 <span class="preprocessor"></span>
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 
<a name="l00122"></a>00122 <span class="comment">/* Define the GL API pointers */</span>
<a name="l00123"></a>00123 <span class="preprocessor">#define AGL_API(type, name, args) AGL_##name##_t __agl##name = NULL;</span>
<a name="l00124"></a>00124 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_api.h&quot;</span>
<a name="l00125"></a>00125 <span class="preprocessor">#undef AGL_API</span>
<a name="l00126"></a>00126 <span class="preprocessor"></span><span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00127"></a>00127 <span class="preprocessor"></span><span class="preprocessor">#define AGL_API(type, name, args) AGL_##name##_t __awgl##name = NULL;</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/wgl_ext_api.h&quot;</span>
<a name="l00129"></a>00129 <span class="preprocessor">#undef AGL_API</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span><span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span><span class="preprocessor">#define AGL_API(type, name, args) AGL_##name##_t __aglX##name = NULL;</span>
<a name="l00132"></a>00132 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/glx_ext_api.h&quot;</span>
<a name="l00133"></a>00133 <span class="preprocessor">#undef AGL_API</span>
<a name="l00134"></a>00134 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00135"></a>00135 <span class="preprocessor"></span>
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 
<a name="l00138"></a>00138 <span class="comment">/* Create the extension table */</span>
<a name="l00139"></a>00139 AGL_EXT* __allegro_gl_create_extensions() {
<a name="l00140"></a>00140 
<a name="l00141"></a>00141     AGL_EXT *ret = malloc(<span class="keyword">sizeof</span>(AGL_EXT));
<a name="l00142"></a>00142 
<a name="l00143"></a>00143     <span class="keywordflow">if</span> (!ret) {
<a name="l00144"></a>00144         <span class="keywordflow">return</span> NULL;
<a name="l00145"></a>00145     }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147     memset(ret, 0, <span class="keyword">sizeof</span>(AGL_EXT));
<a name="l00148"></a>00148 
<a name="l00149"></a>00149     <span class="keywordflow">return</span> ret;
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151 
<a name="l00152"></a>00152 
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <span class="comment">/* Load the extension addresses into the table.</span>
<a name="l00155"></a>00155 <span class="comment"> * Should only be done on context creation.</span>
<a name="l00156"></a>00156 <span class="comment"> */</span>
<a name="l00157"></a>00157 <span class="keywordtype">void</span> __allegro_gl_load_extensions(AGL_EXT *ext) {
<a name="l00158"></a>00158 
<a name="l00159"></a>00159 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00160"></a>00160 <span class="preprocessor"></span>    CFStringRef function;
<a name="l00161"></a>00161 <span class="preprocessor">#endif</span>
<a name="l00162"></a>00162 <span class="preprocessor"></span>
<a name="l00163"></a>00163     <span class="keywordflow">if</span> (!ext) {
<a name="l00164"></a>00164         <span class="keywordflow">return</span>;
<a name="l00165"></a>00165     }
<a name="l00166"></a>00166 <span class="preprocessor">#ifdef ALLEGRO_UNIX</span>
<a name="l00167"></a>00167 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (!aglXGetProcAddress) {
<a name="l00168"></a>00168         <span class="keywordflow">return</span>;
<a name="l00169"></a>00169     }
<a name="l00170"></a>00170 <span class="preprocessor">#endif</span>
<a name="l00171"></a>00171 <span class="preprocessor"></span>
<a name="l00172"></a>00172 <span class="preprocessor">#   ifdef ALLEGRO_WINDOWS</span>
<a name="l00173"></a>00173 <span class="preprocessor"></span><span class="preprocessor">#   define AGL_API(type, name, args) \</span>
<a name="l00174"></a>00174 <span class="preprocessor">        ext-&gt;name = (AGL_##name##_t)wglGetProcAddress(&quot;gl&quot; #name); \</span>
<a name="l00175"></a>00175 <span class="preprocessor">        if (ext-&gt;name) { AGL_LOG(2,&quot;gl&quot; #name &quot; successfully loaded\n&quot;); }</span>
<a name="l00176"></a>00176 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_api.h&quot;</span>
<a name="l00177"></a>00177 <span class="preprocessor">#   undef AGL_API</span>
<a name="l00178"></a>00178 <span class="preprocessor"></span><span class="preprocessor">#   define AGL_API(type, name, args) \</span>
<a name="l00179"></a>00179 <span class="preprocessor">        ext-&gt;name = (AGL_##name##_t)wglGetProcAddress(&quot;wgl&quot; #name); \</span>
<a name="l00180"></a>00180 <span class="preprocessor">        if (ext-&gt;name) { AGL_LOG(2,&quot;wgl&quot; #name &quot; successfully loaded\n&quot;); }</span>
<a name="l00181"></a>00181 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/wgl_ext_api.h&quot;</span>
<a name="l00182"></a>00182 <span class="preprocessor">#   undef AGL_API</span>
<a name="l00183"></a>00183 <span class="preprocessor"></span><span class="preprocessor">#   elif defined ALLEGRO_UNIX</span>
<a name="l00184"></a>00184 <span class="preprocessor"></span><span class="preprocessor">#   define AGL_API(type, name, args) \</span>
<a name="l00185"></a>00185 <span class="preprocessor">        ext-&gt;name = (AGL_##name##_t)aglXGetProcAddress((const GLubyte*)&quot;gl&quot; #name); \</span>
<a name="l00186"></a>00186 <span class="preprocessor">        if (ext-&gt;name) { AGL_LOG(2,&quot;gl&quot; #name &quot; successfully loaded\n&quot;); }</span>
<a name="l00187"></a>00187 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_api.h&quot;</span>
<a name="l00188"></a>00188 <span class="preprocessor">#   undef AGL_API</span>
<a name="l00189"></a>00189 <span class="preprocessor"></span><span class="preprocessor">#   define AGL_API(type, name, args) \</span>
<a name="l00190"></a>00190 <span class="preprocessor">        ext-&gt;name = (AGL_##name##_t)aglXGetProcAddress((const GLubyte*)&quot;glX&quot; #name); \</span>
<a name="l00191"></a>00191 <span class="preprocessor">        if (ext-&gt;name) { AGL_LOG(2,&quot;glX&quot; #name &quot; successfully loaded\n&quot;); }</span>
<a name="l00192"></a>00192 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/glx_ext_api.h&quot;</span>
<a name="l00193"></a>00193 <span class="preprocessor">#   undef AGL_API</span>
<a name="l00194"></a>00194 <span class="preprocessor"></span><span class="preprocessor">#   elif defined ALLEGRO_MACOSX</span>
<a name="l00195"></a>00195 <span class="preprocessor"></span><span class="preprocessor">#   define AGL_API(type, name, args)                                          \</span>
<a name="l00196"></a>00196 <span class="preprocessor">        function = CFStringCreateWithCString(kCFAllocatorDefault, &quot;gl&quot; #name, \</span>
<a name="l00197"></a>00197 <span class="preprocessor">                                                     kCFStringEncodingASCII); \</span>
<a name="l00198"></a>00198 <span class="preprocessor">        if (function) {                                                       \</span>
<a name="l00199"></a>00199 <span class="preprocessor">            ext-&gt;name = (AGL_##name##_t)CFBundleGetFunctionPointerForName(    \</span>
<a name="l00200"></a>00200 <span class="preprocessor">                                             opengl_bundle_ref, function);    \</span>
<a name="l00201"></a>00201 <span class="preprocessor">            CFRelease(function);                                              \</span>
<a name="l00202"></a>00202 <span class="preprocessor">        }                                                                     \</span>
<a name="l00203"></a>00203 <span class="preprocessor">        if (ext-&gt;name) { AGL_LOG(2,&quot;gl&quot; #name &quot; successfully loaded\n&quot;); }</span>
<a name="l00204"></a>00204 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_api.h&quot;</span>
<a name="l00205"></a>00205 <span class="preprocessor">#   undef AGL_API</span>
<a name="l00206"></a>00206 <span class="preprocessor"></span><span class="preprocessor">#   endif</span>
<a name="l00207"></a>00207 <span class="preprocessor"></span>}
<a name="l00208"></a>00208 
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 
<a name="l00211"></a>00211 <span class="comment">/* Set the GL API pointers to the current table </span>
<a name="l00212"></a>00212 <span class="comment"> * Should only be called on context switches.</span>
<a name="l00213"></a>00213 <span class="comment"> */</span>
<a name="l00214"></a>00214 <span class="keywordtype">void</span> __allegro_gl_set_extensions(AGL_EXT *ext) {
<a name="l00215"></a>00215 
<a name="l00216"></a>00216     <span class="keywordflow">if</span> (!ext) {
<a name="l00217"></a>00217         <span class="keywordflow">return</span>;
<a name="l00218"></a>00218     }
<a name="l00219"></a>00219 
<a name="l00220"></a>00220 <span class="preprocessor">#define AGL_API(type, name, args) __agl##name = ext-&gt;name;</span>
<a name="l00221"></a>00221 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_api.h&quot;</span>
<a name="l00222"></a>00222 <span class="preprocessor">#undef AGL_API</span>
<a name="l00223"></a>00223 <span class="preprocessor"></span><span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00224"></a>00224 <span class="preprocessor"></span><span class="preprocessor">#define AGL_API(type, name, args) __awgl##name = ext-&gt;name;</span>
<a name="l00225"></a>00225 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/wgl_ext_api.h&quot;</span>
<a name="l00226"></a>00226 <span class="preprocessor">#undef AGL_API</span>
<a name="l00227"></a>00227 <span class="preprocessor"></span><span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00228"></a>00228 <span class="preprocessor"></span><span class="preprocessor">#define AGL_API(type, name, args) __aglX##name = ext-&gt;name;</span>
<a name="l00229"></a>00229 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/glx_ext_api.h&quot;</span>
<a name="l00230"></a>00230 <span class="preprocessor">#undef AGL_API</span>
<a name="l00231"></a>00231 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00232"></a>00232 <span class="preprocessor"></span>}
<a name="l00233"></a>00233 
<a name="l00234"></a>00234 
<a name="l00235"></a>00235 
<a name="l00236"></a>00236 <span class="comment">/* Destroys the extension table */</span>
<a name="l00237"></a>00237 <span class="keywordtype">void</span> __allegro_gl_destroy_extensions(AGL_EXT *ext) {
<a name="l00238"></a>00238 
<a name="l00239"></a>00239     <span class="keywordflow">if</span> (ext) {
<a name="l00240"></a>00240         <span class="keywordflow">if</span> (ext == agl_extension_table) {
<a name="l00241"></a>00241             agl_extension_table = NULL;
<a name="l00242"></a>00242         }
<a name="l00243"></a>00243         free(ext);
<a name="l00244"></a>00244     }
<a name="l00245"></a>00245 }
<a name="l00246"></a>00246 
<a name="l00247"></a>00247 
<a name="l00248"></a>00248 
<a name="l00249"></a>00249 <span class="comment">/* __allegro_gl_look_for_an_extension:</span>
<a name="l00250"></a>00250 <span class="comment"> * This function has been written by Mark J. Kilgard in one of his</span>
<a name="l00251"></a>00251 <span class="comment"> * tutorials about OpenGL extensions</span>
<a name="l00252"></a>00252 <span class="comment"> */</span>
<a name="l00253"></a>00253 <span class="keywordtype">int</span> __allegro_gl_look_for_an_extension(AL_CONST <span class="keywordtype">char</span> *name,
<a name="l00254"></a>00254                                                   AL_CONST GLubyte * extensions)
<a name="l00255"></a>00255 {
<a name="l00256"></a>00256     AL_CONST GLubyte *start;
<a name="l00257"></a>00257     GLubyte *where, *terminator;
<a name="l00258"></a>00258 
<a name="l00259"></a>00259     <span class="comment">/* Extension names should not have spaces. */</span>
<a name="l00260"></a>00260     where = (GLubyte *) strchr(name, <span class="charliteral">&#39; &#39;</span>);
<a name="l00261"></a>00261     <span class="keywordflow">if</span> (where || *name == <span class="charliteral">&#39;\0&#39;</span>)
<a name="l00262"></a>00262         <span class="keywordflow">return</span> FALSE;
<a name="l00263"></a>00263     <span class="comment">/* It takes a bit of care to be fool-proof about parsing the</span>
<a name="l00264"></a>00264 <span class="comment">     * OpenGL extensions string. Don&#39;t be fooled by sub-strings, etc.</span>
<a name="l00265"></a>00265 <span class="comment">     */</span>
<a name="l00266"></a>00266     start = extensions;
<a name="l00267"></a>00267     <span class="keywordflow">for</span> (;;) {
<a name="l00268"></a>00268         where = (GLubyte *) strstr((AL_CONST <span class="keywordtype">char</span> *) start, name);
<a name="l00269"></a>00269         <span class="keywordflow">if</span> (!where)
<a name="l00270"></a>00270         <span class="keywordflow">break</span>;
<a name="l00271"></a>00271         terminator = where + strlen(name);
<a name="l00272"></a>00272         <span class="keywordflow">if</span> (where == start || *(where - 1) == <span class="charliteral">&#39; &#39;</span>)
<a name="l00273"></a>00273             <span class="keywordflow">if</span> (*terminator == <span class="charliteral">&#39; &#39;</span> || *terminator == <span class="charliteral">&#39;\0&#39;</span>)
<a name="l00274"></a>00274                 <span class="keywordflow">return</span> TRUE;
<a name="l00275"></a>00275         start = terminator;
<a name="l00276"></a>00276     }
<a name="l00277"></a>00277     <span class="keywordflow">return</span> FALSE;
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 
<a name="l00280"></a>00280 
<a name="l00281"></a>00281 
<a name="l00282"></a>00282 <span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00283"></a>00283 <span class="preprocessor"></span><span class="keyword">static</span> AGL_GetExtensionsStringARB_t __wglGetExtensionsStringARB = NULL;
<a name="l00284"></a>00284 <span class="keyword">static</span> HDC __hdc = NULL;
<a name="l00285"></a>00285 <span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00286"></a>00286 <span class="preprocessor"></span><span class="preprocessor">#include &lt;xalleg.h&gt;</span>
<a name="l00287"></a>00287 <span class="preprocessor">#endif</span>
<a name="l00288"></a>00288 <span class="preprocessor"></span>
<a name="l00289"></a>00289 
<a name="l00290"></a>00290 <span class="comment">/* int allegro_gl_is_extension_supported(AL_CONST char *extension) */</span>
<a name="l00306"></a><a class="code" href="group__extensions.html#ga7351f56ea1c4f4665193fc3bf547ff0a">00306</a> <span class="keywordtype">int</span> <a class="code" href="group__extensions.html#ga7351f56ea1c4f4665193fc3bf547ff0a" title="This function is an helper to determine whether an OpenGL extension is available or not...">allegro_gl_is_extension_supported</a>(AL_CONST <span class="keywordtype">char</span> *extension)
<a name="l00307"></a>00307 {
<a name="l00308"></a>00308     <span class="keywordtype">int</span> ret;
<a name="l00309"></a>00309     
<a name="l00310"></a>00310     <span class="keywordflow">if</span> (!__allegro_gl_valid_context)
<a name="l00311"></a>00311         <span class="keywordflow">return</span> FALSE;
<a name="l00312"></a>00312 
<a name="l00313"></a>00313     <span class="keywordflow">if</span> (!glGetString(GL_EXTENSIONS))
<a name="l00314"></a>00314         <span class="keywordflow">return</span> FALSE;
<a name="l00315"></a>00315 
<a name="l00316"></a>00316     ret = __allegro_gl_look_for_an_extension(extension,
<a name="l00317"></a>00317                                                   glGetString(GL_EXTENSIONS));
<a name="l00318"></a>00318 
<a name="l00319"></a>00319 <span class="preprocessor">#ifdef ALLEGRO_WINDOWS</span>
<a name="l00320"></a>00320 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (!ret &amp;&amp; strncmp(extension, <span class="stringliteral">&quot;WGL&quot;</span>, 3) == 0) {
<a name="l00321"></a>00321         <span class="keywordflow">if</span> (!__wglGetExtensionsStringARB || __hdc != __allegro_gl_hdc) {
<a name="l00322"></a>00322             __wglGetExtensionsStringARB = (AGL_GetExtensionsStringARB_t)
<a name="l00323"></a>00323                                wglGetProcAddress(<span class="stringliteral">&quot;wglGetExtensionsStringARB&quot;</span>);
<a name="l00324"></a>00324             __hdc = __allegro_gl_hdc;
<a name="l00325"></a>00325         }
<a name="l00326"></a>00326         <span class="keywordflow">if</span> (__wglGetExtensionsStringARB) {
<a name="l00327"></a>00327             ret = __allegro_gl_look_for_an_extension(extension,
<a name="l00328"></a>00328                        (AL_CONST GLubyte*)__wglGetExtensionsStringARB(__allegro_gl_hdc));
<a name="l00329"></a>00329         }
<a name="l00330"></a>00330     }
<a name="l00331"></a>00331 <span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00332"></a>00332 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (!ret &amp;&amp; strncmp(extension, <span class="stringliteral">&quot;GLX&quot;</span>, 3) == 0) {
<a name="l00333"></a>00333         XLOCK();
<a name="l00334"></a>00334         ret = __allegro_gl_look_for_an_extension(extension,
<a name="l00335"></a>00335                 (<span class="keyword">const</span> GLubyte*)glXQueryExtensionsString(_xwin.display,
<a name="l00336"></a>00336                                                          _xwin.screen));
<a name="l00337"></a>00337         XUNLOCK();
<a name="l00338"></a>00338     }
<a name="l00339"></a>00339 <span class="preprocessor">#endif</span>
<a name="l00340"></a>00340 <span class="preprocessor"></span>
<a name="l00341"></a>00341     <span class="keywordflow">return</span> ret;
<a name="l00342"></a>00342 }
<a name="l00343"></a>00343 
<a name="l00344"></a>00344 
<a name="l00345"></a>00345 
<a name="l00346"></a>00346 <span class="comment">/* void * allegro_gl_get_proc_address(AL_CONST char *name) */</span>
<a name="l00372"></a><a class="code" href="group__extensions.html#gaa0c2cd7c4b4a94e8801af42a58356cc4">00372</a> <span class="keywordtype">void</span> *<a class="code" href="group__extensions.html#gaa0c2cd7c4b4a94e8801af42a58356cc4" title="Helper to get the address of an OpenGL symbol.">allegro_gl_get_proc_address</a>(AL_CONST <span class="keywordtype">char</span> *name)
<a name="l00373"></a>00373 {
<a name="l00374"></a>00374     <span class="keywordtype">void</span> *symbol = NULL;
<a name="l00375"></a>00375 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00376"></a>00376 <span class="preprocessor"></span>    CFStringRef function;
<a name="l00377"></a>00377 <span class="preprocessor">#endif</span>
<a name="l00378"></a>00378 <span class="preprocessor"></span>
<a name="l00379"></a>00379     <span class="keywordflow">if</span> (!__allegro_gl_valid_context)
<a name="l00380"></a>00380         <span class="keywordflow">return</span> NULL;
<a name="l00381"></a>00381 
<a name="l00382"></a>00382 <span class="preprocessor">#ifdef ALLEGROGL_GENERIC_DRIVER</span>
<a name="l00383"></a>00383 <span class="preprocessor"></span>    <span class="comment">/* AMesa provides a function to get a proc address. It does</span>
<a name="l00384"></a>00384 <span class="comment">     * not emulate dynamic linking of course...</span>
<a name="l00385"></a>00385 <span class="comment">     */</span>
<a name="l00386"></a>00386     symbol = AMesaGetProcAddress(name);
<a name="l00387"></a>00387 
<a name="l00388"></a>00388 <span class="preprocessor">#elif defined ALLEGRO_WINDOWS</span>
<a name="l00389"></a>00389 <span class="preprocessor"></span>    <span class="comment">/* For once Windows is the easiest platform to use :)</span>
<a name="l00390"></a>00390 <span class="comment">     * It provides a standardized way to get a function address</span>
<a name="l00391"></a>00391 <span class="comment">     * But of course there is a drawback : the symbol is only valid</span>
<a name="l00392"></a>00392 <span class="comment">     * under the current context :P</span>
<a name="l00393"></a>00393 <span class="comment">     */</span>
<a name="l00394"></a>00394     symbol = wglGetProcAddress(name);
<a name="l00395"></a>00395 <span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00396"></a>00396 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (aglXGetProcAddress) {
<a name="l00397"></a>00397         <span class="comment">/* This is definitely the *good* way on Unix to get a GL proc</span>
<a name="l00398"></a>00398 <span class="comment">         * address. Unfortunately glXGetProcAddress is an extension</span>
<a name="l00399"></a>00399 <span class="comment">         * and may not be available on all platforms</span>
<a name="l00400"></a>00400 <span class="comment">         */</span>
<a name="l00401"></a>00401         symbol = aglXGetProcAddress((<span class="keyword">const</span> GLubyte*)name);
<a name="l00402"></a>00402     }
<a name="l00403"></a>00403 <span class="preprocessor">#elif defined ALLEGROGL_HAVE_DYNAMIC_LINK</span>
<a name="l00404"></a>00404 <span class="preprocessor"></span>    <span class="keywordflow">else</span> {
<a name="l00405"></a>00405         <span class="comment">/* Hack if glXGetProcAddress is not available :</span>
<a name="l00406"></a>00406 <span class="comment">         * we try to find the symbol into libGL.so</span>
<a name="l00407"></a>00407 <span class="comment">         */</span>
<a name="l00408"></a>00408         <span class="keywordflow">if</span> (__agl_handle) {
<a name="l00409"></a>00409             symbol = dlsym(__agl_handle, name);
<a name="l00410"></a>00410         }
<a name="l00411"></a>00411     }
<a name="l00412"></a>00412 <span class="preprocessor">#elif defined ALLEGRO_MACOSX</span>
<a name="l00413"></a>00413 <span class="preprocessor"></span>    function = CFStringCreateWithCString(kCFAllocatorDefault, name,
<a name="l00414"></a>00414                                          kCFStringEncodingASCII);
<a name="l00415"></a>00415     <span class="keywordflow">if</span> (function) {
<a name="l00416"></a>00416         symbol = CFBundleGetFunctionPointerForName(opengl_bundle_ref, function);
<a name="l00417"></a>00417         CFRelease(function);
<a name="l00418"></a>00418     }
<a name="l00419"></a>00419 <span class="preprocessor">#else</span>
<a name="l00420"></a>00420 <span class="preprocessor"></span>    <span class="comment">/* DOS does not support dynamic linking. If the function is not</span>
<a name="l00421"></a>00421 <span class="comment">     * available at build-time then it will not be available at run-time</span>
<a name="l00422"></a>00422 <span class="comment">     * Therefore we do not need to look for it...</span>
<a name="l00423"></a>00423 <span class="comment">     */</span>
<a name="l00424"></a>00424 <span class="preprocessor">#endif</span>
<a name="l00425"></a>00425 <span class="preprocessor"></span>
<a name="l00426"></a>00426     <span class="keywordflow">if</span> (!symbol) {
<a name="l00427"></a>00427 
<a name="l00428"></a>00428 <span class="preprocessor">#if defined ALLEGROGL_HAVE_DYNAMIC_LINK</span>
<a name="l00429"></a>00429 <span class="preprocessor"></span>        <span class="keywordflow">if</span> (!aglXGetProcAddress) {
<a name="l00430"></a>00430             TRACE(PREFIX_W <span class="stringliteral">&quot;get_proc_address: libdl::dlsym: %s\n&quot;</span>,
<a name="l00431"></a>00431                   dlerror());
<a name="l00432"></a>00432         }
<a name="l00433"></a>00433 <span class="preprocessor">#endif</span>
<a name="l00434"></a>00434 <span class="preprocessor"></span>        
<a name="l00435"></a>00435         TRACE(PREFIX_W <span class="stringliteral">&quot;get_proc_address : Unable to load symbol %s\n&quot;</span>,
<a name="l00436"></a>00436               name);
<a name="l00437"></a>00437     }
<a name="l00438"></a>00438     <span class="keywordflow">else</span> {
<a name="l00439"></a>00439         TRACE(PREFIX_I <span class="stringliteral">&quot;get_proc_address : Symbol %s successfully loaded\n&quot;</span>,
<a name="l00440"></a>00440               name);
<a name="l00441"></a>00441     }
<a name="l00442"></a>00442     <span class="keywordflow">return</span> symbol;
<a name="l00443"></a>00443 }
<a name="l00444"></a>00444 
<a name="l00445"></a>00445 
<a name="l00446"></a>00446 
<a name="l00447"></a>00447 <span class="comment">/* Fills in the AllegroGL info struct for blacklisting video cards.</span>
<a name="l00448"></a>00448 <span class="comment"> */</span>
<a name="l00449"></a>00449 <span class="keyword">static</span> <span class="keywordtype">void</span> __fill_in_info_struct(<span class="keyword">const</span> GLubyte *rendereru,
<a name="l00450"></a>00450                                   <span class="keyword">struct</span> allegro_gl_info *info) {
<a name="l00451"></a>00451     <span class="keyword">const</span> <span class="keywordtype">char</span> *renderer = (<span class="keyword">const</span> <span class="keywordtype">char</span>*)rendereru;
<a name="l00452"></a>00452     
<a name="l00453"></a>00453     <span class="comment">/* Some cards are &quot;special&quot;... */</span>
<a name="l00454"></a>00454     <span class="keywordflow">if</span> (strstr(renderer, <span class="stringliteral">&quot;3Dfx/Voodoo&quot;</span>)) {
<a name="l00455"></a>00455         info-&gt;is_voodoo = 1;
<a name="l00456"></a>00456     }
<a name="l00457"></a>00457     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strstr(renderer, <span class="stringliteral">&quot;Matrox G200&quot;</span>)) {
<a name="l00458"></a>00458         info-&gt;is_matrox_g200 = 1;
<a name="l00459"></a>00459     }
<a name="l00460"></a>00460     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strstr(renderer, <span class="stringliteral">&quot;RagePRO&quot;</span>)) {
<a name="l00461"></a>00461         info-&gt;is_ati_rage_pro = 1;
<a name="l00462"></a>00462     }
<a name="l00463"></a>00463     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strstr(renderer, <span class="stringliteral">&quot;RADEON 7000&quot;</span>)) {
<a name="l00464"></a>00464         info-&gt;is_ati_radeon_7000 = 1;
<a name="l00465"></a>00465     }
<a name="l00466"></a>00466     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strstr(renderer, <span class="stringliteral">&quot;Mesa DRI R200&quot;</span>)) {
<a name="l00467"></a>00467         info-&gt;is_ati_r200_chip = 1;
<a name="l00468"></a>00468     }
<a name="l00469"></a>00469 
<a name="l00470"></a>00470     <span class="keywordflow">if</span> ((strncmp(renderer, <span class="stringliteral">&quot;3Dfx/Voodoo3 &quot;</span>, 13) == 0)
<a name="l00471"></a>00471      || (strncmp(renderer, <span class="stringliteral">&quot;3Dfx/Voodoo2 &quot;</span>, 13) == 0) 
<a name="l00472"></a>00472      || (strncmp(renderer, <span class="stringliteral">&quot;3Dfx/Voodoo &quot;</span>, 12) == 0)) {
<a name="l00473"></a>00473         info-&gt;is_voodoo3_and_under = 1;
<a name="l00474"></a>00474     }
<a name="l00475"></a>00475 
<a name="l00476"></a>00476     <span class="comment">/* Read OpenGL properties */</span>    
<a name="l00477"></a>00477     info-&gt;version = <a class="code" href="group__core.html#ga444d507eaeb5ba800787f6a81827615d" title="Returns the OpenGL version number of the client (the computer the program is running on)...">allegro_gl_opengl_version</a>();
<a name="l00478"></a>00478 
<a name="l00479"></a>00479     <span class="keywordflow">return</span>;
<a name="l00480"></a>00480 }
<a name="l00481"></a>00481 
<a name="l00482"></a>00482 
<a name="l00483"></a>00483 
<a name="l00484"></a>00484 <span class="comment">/* __allegro_gl_manage_extensions:</span>
<a name="l00485"></a>00485 <span class="comment"> * This functions fills the __allegro_gl_extensions structure and displays</span>
<a name="l00486"></a>00486 <span class="comment"> * on the log file which extensions are available</span>
<a name="l00487"></a>00487 <span class="comment"> */</span>
<a name="l00488"></a>00488 <span class="keywordtype">void</span> __allegro_gl_manage_extensions(<span class="keywordtype">void</span>)
<a name="l00489"></a>00489 {
<a name="l00490"></a>00490     AL_CONST GLubyte *buf;
<a name="l00491"></a>00491     <span class="keywordtype">int</span> i;
<a name="l00492"></a>00492 
<a name="l00493"></a>00493 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00494"></a>00494 <span class="preprocessor"></span>    CFURLRef bundle_url;
<a name="l00495"></a>00495 <span class="preprocessor">#endif</span>
<a name="l00496"></a>00496 <span class="preprocessor"></span>
<a name="l00497"></a>00497     <span class="comment">/* Print out OpenGL extensions */</span>
<a name="l00498"></a>00498 <span class="preprocessor">#if LOGLEVEL &gt;= 1</span>
<a name="l00499"></a>00499 <span class="preprocessor"></span>    AGL_LOG(1, <span class="stringliteral">&quot;OpenGL Extensions:\n&quot;</span>);
<a name="l00500"></a>00500              __allegro_gl_print_extensions((AL_CONST <span class="keywordtype">char</span>*)
<a name="l00501"></a>00501             glGetString(GL_EXTENSIONS));
<a name="l00502"></a>00502 <span class="preprocessor">#endif</span>
<a name="l00503"></a>00503 <span class="preprocessor"></span>    
<a name="l00504"></a>00504     <span class="comment">/* Print out GLU version */</span>
<a name="l00505"></a>00505     buf = gluGetString(GLU_VERSION);
<a name="l00506"></a>00506     TRACE(PREFIX_I <span class="stringliteral">&quot;GLU Version : %s\n&quot;</span>, buf);
<a name="l00507"></a>00507 
<a name="l00508"></a>00508 <span class="preprocessor">#ifdef ALLEGROGL_HAVE_DYNAMIC_LINK</span>
<a name="l00509"></a>00509 <span class="preprocessor"></span>    <span class="comment">/* Get glXGetProcAddress entry */</span>
<a name="l00510"></a>00510     __agl_handle = dlopen(<span class="stringliteral">&quot;libGL.so&quot;</span>, RTLD_LAZY);
<a name="l00511"></a>00511     <span class="keywordflow">if</span> (__agl_handle) {
<a name="l00512"></a>00512         aglXGetProcAddress = (GLXGETPROCADDRESSARBPROC) dlsym(__agl_handle,
<a name="l00513"></a>00513                                                         <span class="stringliteral">&quot;glXGetProcAddressARB&quot;</span>);
<a name="l00514"></a>00514         <span class="keywordflow">if</span> (!aglXGetProcAddress) {
<a name="l00515"></a>00515             aglXGetProcAddress = (GLXGETPROCADDRESSARBPROC) dlsym(__agl_handle,
<a name="l00516"></a>00516                                                            <span class="stringliteral">&quot;glXGetProcAddress&quot;</span>);
<a name="l00517"></a>00517         }
<a name="l00518"></a>00518     }
<a name="l00519"></a>00519     <span class="keywordflow">else</span> {
<a name="l00520"></a>00520         TRACE(PREFIX_W <span class="stringliteral">&quot;Failed to dlopen libGL.so : %s\n&quot;</span>, dlerror());
<a name="l00521"></a>00521     }
<a name="l00522"></a>00522     TRACE(PREFIX_I <span class="stringliteral">&quot;glXGetProcAddress Extension: %s\n&quot;</span>,
<a name="l00523"></a>00523                            aglXGetProcAddress ? <span class="stringliteral">&quot;Supported&quot;</span> : <span class="stringliteral">&quot;Unsupported&quot;</span>);
<a name="l00524"></a>00524 <span class="preprocessor">#elif defined ALLEGRO_UNIX</span>
<a name="l00525"></a>00525 <span class="preprocessor"></span><span class="preprocessor">#ifdef ALLEGROGL_GLXGETPROCADDRESSARB</span>
<a name="l00526"></a>00526 <span class="preprocessor"></span>    TRACE(PREFIX_I <span class="stringliteral">&quot;glXGetProcAddressARB Extension: supported\n&quot;</span>);
<a name="l00527"></a>00527 <span class="preprocessor">#else</span>
<a name="l00528"></a>00528 <span class="preprocessor"></span>    TRACE(PREFIX_I <span class="stringliteral">&quot;glXGetProcAddress Extension: supported\n&quot;</span>);
<a name="l00529"></a>00529 <span class="preprocessor">#endif</span>
<a name="l00530"></a>00530 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00531"></a>00531 <span class="preprocessor"></span>    
<a name="l00532"></a>00532 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00533"></a>00533 <span class="preprocessor"></span>    bundle_url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
<a name="l00534"></a>00534                          CFSTR(<span class="stringliteral">&quot;/System/Library/Frameworks/OpenGL.framework&quot;</span>),
<a name="l00535"></a>00535                          kCFURLPOSIXPathStyle, <span class="keyword">true</span>);
<a name="l00536"></a>00536     opengl_bundle_ref = CFBundleCreate(kCFAllocatorDefault, bundle_url);
<a name="l00537"></a>00537     CFRelease(bundle_url);
<a name="l00538"></a>00538 <span class="preprocessor">#endif</span>
<a name="l00539"></a>00539 <span class="preprocessor"></span>
<a name="l00540"></a>00540     __fill_in_info_struct(glGetString(GL_RENDERER), &amp;allegro_gl_info);
<a name="l00541"></a>00541 
<a name="l00542"></a>00542     <span class="comment">/* Load extensions */</span>
<a name="l00543"></a>00543     agl_extension_table = __allegro_gl_create_extensions();
<a name="l00544"></a>00544     __allegro_gl_load_extensions(agl_extension_table);
<a name="l00545"></a>00545     __allegro_gl_set_extensions(agl_extension_table);
<a name="l00546"></a>00546     
<a name="l00547"></a>00547     <span class="keywordflow">for</span> (i = 0; i &lt; 5; i++) {
<a name="l00548"></a>00548         __allegro_gl_texture_read_format[i] = -1;
<a name="l00549"></a>00549         __allegro_gl_texture_components[i] = GL_RGB;
<a name="l00550"></a>00550     }
<a name="l00551"></a>00551     __allegro_gl_texture_read_format[3] = GL_UNSIGNED_BYTE;
<a name="l00552"></a>00552     __allegro_gl_texture_read_format[4] = GL_UNSIGNED_BYTE;
<a name="l00553"></a>00553     __allegro_gl_texture_components[4] = GL_RGBA;
<a name="l00554"></a>00554 
<a name="l00555"></a>00555     
<a name="l00556"></a>00556     <span class="comment">/* Get extension info for the rest of the lib */</span>
<a name="l00557"></a>00557 <span class="preprocessor">#    define AGL_EXT(name, ver) {                               \</span>
<a name="l00558"></a>00558 <span class="preprocessor">        allegro_gl_extensions_GL.name =                        \</span>
<a name="l00559"></a>00559 <span class="preprocessor">              allegro_gl_is_extension_supported(&quot;GL_&quot; #name)   \</span>
<a name="l00560"></a>00560 <span class="preprocessor">          || (allegro_gl_info.version &gt;= ver &amp;&amp; ver &gt; 0);      \</span>
<a name="l00561"></a>00561 <span class="preprocessor">    }</span>
<a name="l00562"></a>00562 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/gl_ext_list.h&quot;</span>
<a name="l00563"></a>00563 <span class="preprocessor">#   undef AGL_EXT</span>
<a name="l00564"></a>00564 <span class="preprocessor"></span>
<a name="l00565"></a>00565 <span class="preprocessor">#ifdef ALLEGRO_UNIX</span>
<a name="l00566"></a>00566 <span class="preprocessor"></span><span class="preprocessor">#    define AGL_EXT(name, ver) {                               \</span>
<a name="l00567"></a>00567 <span class="preprocessor">        allegro_gl_extensions_GLX.name =                       \</span>
<a name="l00568"></a>00568 <span class="preprocessor">              allegro_gl_is_extension_supported(&quot;GLX_&quot; #name)  \</span>
<a name="l00569"></a>00569 <span class="preprocessor">          || (allegro_gl_info.version &gt;= ver &amp;&amp; ver &gt; 0);      \</span>
<a name="l00570"></a>00570 <span class="preprocessor">    }</span>
<a name="l00571"></a>00571 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/glx_ext_list.h&quot;</span>
<a name="l00572"></a>00572 <span class="preprocessor">#   undef AGL_EXT</span>
<a name="l00573"></a>00573 <span class="preprocessor"></span><span class="preprocessor">#elif defined ALLEGRO_WINDOWS</span>
<a name="l00574"></a>00574 <span class="preprocessor"></span><span class="preprocessor">#    define AGL_EXT(name, ver) {                               \</span>
<a name="l00575"></a>00575 <span class="preprocessor">        allegro_gl_extensions_WGL.name =                       \</span>
<a name="l00576"></a>00576 <span class="preprocessor">              allegro_gl_is_extension_supported(&quot;WGL_&quot; #name)  \</span>
<a name="l00577"></a>00577 <span class="preprocessor">          || (allegro_gl_info.version &gt;= ver &amp;&amp; ver &gt; 0);      \</span>
<a name="l00578"></a>00578 <span class="preprocessor">    }</span>
<a name="l00579"></a>00579 <span class="preprocessor"></span><span class="preprocessor">#   include &quot;allegrogl/GLext/wgl_ext_list.h&quot;</span>
<a name="l00580"></a>00580 <span class="preprocessor">#   undef AGL_EXT</span>
<a name="l00581"></a>00581 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00582"></a>00582 <span class="preprocessor"></span>    
<a name="l00583"></a>00583     <span class="comment">/* Get number of texture units */</span>
<a name="l00584"></a>00584     <span class="keywordflow">if</span> (<a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.ARB_multitexture) {
<a name="l00585"></a>00585         glGetIntegerv(GL_MAX_TEXTURE_UNITS,
<a name="l00586"></a>00586                       (GLint*)&amp;allegro_gl_info.num_texture_units);
<a name="l00587"></a>00587     }
<a name="l00588"></a>00588     <span class="keywordflow">else</span> {
<a name="l00589"></a>00589         allegro_gl_info.num_texture_units = 1;
<a name="l00590"></a>00590     }
<a name="l00591"></a>00591 
<a name="l00592"></a>00592     <span class="comment">/* Get max texture size */</span>
<a name="l00593"></a>00593     glGetIntegerv(GL_MAX_TEXTURE_SIZE,
<a name="l00594"></a>00594                   (GLint*)&amp;allegro_gl_info.max_texture_size);
<a name="l00595"></a>00595 
<a name="l00596"></a>00596     <span class="comment">/* Note: Voodoo (even V5) don&#39;t seem to correctly support</span>
<a name="l00597"></a>00597 <span class="comment">     * packed pixel formats. Disabling them for those cards.</span>
<a name="l00598"></a>00598 <span class="comment">     */</span>
<a name="l00599"></a>00599     <a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.EXT_packed_pixels &amp;= !allegro_gl_info.is_voodoo;
<a name="l00600"></a>00600 
<a name="l00601"></a>00601     
<a name="l00602"></a>00602     <span class="keywordflow">if</span> (<a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.EXT_packed_pixels) {
<a name="l00603"></a>00603 
<a name="l00604"></a>00604         AGL_LOG(1, <span class="stringliteral">&quot;Packed Pixels formats available\n&quot;</span>);
<a name="l00605"></a>00605 
<a name="l00606"></a>00606         <span class="comment">/* XXX On NV cards, we want to use BGRA instead of RGBA for speed */</span>
<a name="l00607"></a>00607         <span class="comment">/* Fills the __allegro_gl_texture_format array */</span>
<a name="l00608"></a>00608         __allegro_gl_texture_read_format[0] = GL_UNSIGNED_BYTE_3_3_2;
<a name="l00609"></a>00609         __allegro_gl_texture_read_format[1] = GL_UNSIGNED_SHORT_5_5_5_1;
<a name="l00610"></a>00610         __allegro_gl_texture_read_format[2] = GL_UNSIGNED_SHORT_5_6_5;
<a name="l00611"></a>00611     }
<a name="l00612"></a>00612 
<a name="l00613"></a>00613     <span class="comment">/* NVidia and ATI cards expose OpenGL 2.0 but often don&#39;t accelerate</span>
<a name="l00614"></a>00614 <span class="comment">     * non-power-of-2 textures. This check is how you verify that NP2</span>
<a name="l00615"></a>00615 <span class="comment">     * textures are hardware accelerated or not.</span>
<a name="l00616"></a>00616 <span class="comment">     * We should clobber the NPOT support if it&#39;s not accelerated.</span>
<a name="l00617"></a>00617 <span class="comment">     */</span>
<a name="l00618"></a>00618     {   <span class="keyword">const</span> <span class="keywordtype">char</span> *vendor = (<span class="keyword">const</span> <span class="keywordtype">char</span>*)glGetString(GL_VENDOR);
<a name="l00619"></a>00619         <span class="keywordflow">if</span> (strstr(vendor, <span class="stringliteral">&quot;NVIDIA Corporation&quot;</span>)) {
<a name="l00620"></a>00620             <span class="keywordflow">if</span> (!<a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.NV_fragment_program2
<a name="l00621"></a>00621              || !<a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.NV_vertex_program3) {
<a name="l00622"></a>00622                 <a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.ARB_texture_non_power_of_two = 0;
<a name="l00623"></a>00623             }
<a name="l00624"></a>00624         }
<a name="l00625"></a>00625         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strstr(vendor, <span class="stringliteral">&quot;ATI Technologies&quot;</span>)) {
<a name="l00626"></a>00626             <span class="keywordflow">if</span> (!strstr((<span class="keyword">const</span> <span class="keywordtype">char</span>*)glGetString(GL_EXTENSIONS),
<a name="l00627"></a>00627                         <span class="stringliteral">&quot;GL_ARB_texture_non_power_of_two&quot;</span>)
<a name="l00628"></a>00628              &amp;&amp; allegro_gl_info.version &gt;= 2.0f) {
<a name="l00629"></a>00629                 <a class="code" href="group__extensions.html#ga7492f6f6acc608789210560ee63e5436" title="List of OpenGL extensions supported by AllegroGL.">allegro_gl_extensions_GL</a>.ARB_texture_non_power_of_two = 0;
<a name="l00630"></a>00630             }
<a name="l00631"></a>00631         }
<a name="l00632"></a>00632     }
<a name="l00633"></a>00633 }
<a name="l00634"></a>00634 
<a name="l00635"></a>00635 
<a name="l00636"></a>00636 
<a name="l00637"></a>00637 <span class="comment">/* __allegro_gl_print_extensions:</span>
<a name="l00638"></a>00638 <span class="comment"> * Given a string containing extensions (i.e. a NULL terminated string where</span>
<a name="l00639"></a>00639 <span class="comment"> * each extension are separated by a space and which names do not contain any</span>
<a name="l00640"></a>00640 <span class="comment"> * space)</span>
<a name="l00641"></a>00641 <span class="comment"> */</span>
<a name="l00642"></a>00642 <span class="keywordtype">void</span> __allegro_gl_print_extensions(AL_CONST <span class="keywordtype">char</span> * extension)
<a name="l00643"></a>00643 {
<a name="l00644"></a>00644         <span class="keywordtype">char</span> buf[80];
<a name="l00645"></a>00645         <span class="keywordtype">char</span>* start;
<a name="l00646"></a>00646 
<a name="l00647"></a>00647         <span class="keywordflow">while</span> (*extension != <span class="charliteral">&#39;\0&#39;</span>) {
<a name="l00648"></a>00648                 start = buf;
<a name="l00649"></a>00649                 strncpy(buf, extension, 80);
<a name="l00650"></a>00650                 <span class="keywordflow">while</span> ((*start != <span class="charliteral">&#39; &#39;</span>) &amp;&amp; (*start != <span class="charliteral">&#39;\0&#39;</span>)) {
<a name="l00651"></a>00651                         extension++;
<a name="l00652"></a>00652                         start++;
<a name="l00653"></a>00653                 }
<a name="l00654"></a>00654                 *start = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00655"></a>00655                 extension ++;
<a name="l00656"></a>00656                 TRACE(PREFIX_I <span class="stringliteral">&quot;%s\n&quot;</span>, buf);
<a name="l00657"></a>00657         }
<a name="l00658"></a>00658 }
<a name="l00659"></a>00659 
<a name="l00660"></a>00660 
<a name="l00661"></a>00661 
<a name="l00662"></a>00662 <span class="keywordtype">void</span> __allegro_gl_unmanage_extensions() {
<a name="l00663"></a>00663     __allegro_gl_destroy_extensions(agl_extension_table);
<a name="l00664"></a>00664 <span class="preprocessor">#ifdef ALLEGRO_MACOSX</span>
<a name="l00665"></a>00665 <span class="preprocessor"></span>    CFRelease(opengl_bundle_ref);
<a name="l00666"></a>00666 <span class="preprocessor">#endif</span>
<a name="l00667"></a>00667 <span class="preprocessor"></span><span class="preprocessor">#ifdef ALLEGROGL_HAVE_DYNAMIC_LINK</span>
<a name="l00668"></a>00668 <span class="preprocessor"></span>    <span class="keywordflow">if</span> (__agl_handle) {
<a name="l00669"></a>00669         dlclose(__agl_handle);
<a name="l00670"></a>00670         __agl_handle = NULL;
<a name="l00671"></a>00671     }
<a name="l00672"></a>00672 <span class="preprocessor">#endif</span>
<a name="l00673"></a>00673 <span class="preprocessor"></span>}
<a name="l00674"></a>00674 
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="glext_8c.html">glext.c</a>      </li>
      <li class="footer">Generated on Thu May 19 2011 23:20:20 for AllegroGL by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>