~vcs-imports/pyopengl/trunk

« back to all changes in this revision

Viewing changes to documentation/development.html

  • Committer: mcfletch
  • Date: 2008-09-10 13:33:47 UTC
  • Revision ID: vcs-imports@canonical.com-20080910133347-9ndtacc8d3hbe9hm
eliminate references to pkg-resources entry points

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
 
<html><head>
3
 
 
4
 
 
5
 
 
6
 
 
7
 
 
8
 
 
9
 
 
10
 
 
11
 
 
12
 
 
 
2
<html>
 
3
<head>
 
4
 
 
5
 
 
6
 
 
7
 
 
8
 
 
9
 
 
10
 
 
11
 
 
12
 
 
13
 
 
14
 
 
15
  
13
16
  
14
17
  
15
18
  
31
34
 
32
35
 
33
36
 
34
 
  
35
 
  
36
 
  
37
 
  
38
 
  
39
 
  
40
 
  
41
 
  
42
 
  
43
 
  
44
 
  
45
 
  
46
 
  
47
 
  
48
 
  
49
 
  
50
 
  
51
 
  
52
 
  
53
 
  
54
 
  
55
 
  <title>Contributing to OpenGL-ctypes</title><link rel="stylesheet" type="text/css" href="style/tutorial.css">
56
 
 
57
 
 
58
 
 
59
 
 
60
 
 
61
 
 
62
 
 
63
 
 
64
 
 
65
 
 
66
 
  
67
 
  
68
 
  
69
 
  
70
 
  
71
 
  
72
 
  
73
 
  
74
 
  
75
 
  
76
 
  <meta name="author" content="Mike C. Fletcher"></head>
 
37
 
 
38
  
 
39
  
 
40
  
 
41
  
 
42
  
 
43
  
 
44
  
 
45
  
 
46
  
 
47
  
 
48
  
 
49
  
 
50
  
 
51
  
 
52
  
 
53
  
 
54
  
 
55
  
 
56
  
 
57
  
 
58
  
 
59
  
 
60
  <title>Contributing to OpenGL-ctypes</title>
 
61
  <link rel="stylesheet" type="text/css" href="style/tutorial.css">
 
62
 
 
63
 
 
64
 
 
65
 
 
66
 
 
67
 
 
68
 
 
69
 
 
70
 
 
71
 
 
72
 
 
73
  
 
74
  
 
75
  
 
76
  
 
77
  
 
78
  
 
79
  
 
80
  
 
81
  
 
82
  
 
83
  
 
84
  <meta name="author" content="Mike C. Fletcher">
 
85
</head>
77
86
 
78
87
<body>
79
88
 
86
95
 
87
96
 
88
97
 
 
98
 
89
99
<h1>Contributing
90
100
to OpenGL-ctypes<br>
91
101
 
98
108
 
99
109
 
100
110
 
 
111
 
101
112
</h1>
102
113
 
103
114
 
109
120
 
110
121
 
111
122
 
 
123
 
112
124
<p class="introduction">This
113
125
document describes how to get started with
114
126
contributing to the OpenGL-ctypes project, the project which is creating the&nbsp;PyOpenGL 3.0.0 release.&nbsp; It outlines the
126
138
 
127
139
 
128
140
 
 
141
 
129
142
</p>
130
143
 
131
144
 
137
150
 
138
151
 
139
152
 
 
153
 
140
154
<h2>The History of OpenGL-ctypes<br>
141
155
 
142
156
 
148
162
 
149
163
 
150
164
 
 
165
 
151
166
</h2>
152
167
 
153
168
 
159
174
 
160
175
 
161
176
 
 
177
 
162
178
<p>OpenGL-ctypes is a
163
179
re-implementation of the OpenGL bindings
164
180
for Python.&nbsp; Historically there were two other mainline
173
189
 
174
190
 
175
191
 
 
192
 
176
193
<ul>
177
194
 
178
195
 
184
201
 
185
202
 
186
203
 
 
204
 
187
205
  <li>PyOpenGL up to 1.x was
188
206
written as a C extension using the raw
189
207
Python C API.&nbsp; It was characterised by a very intuitive
207
225
 
208
226
 
209
227
 
 
228
 
210
229
  </li>
211
230
 
212
231
 
218
237
 
219
238
 
220
239
 
 
240
 
221
241
  <li>PyOpenGL 2.x was written as
222
242
a set of SWIG typemaps (a.k.a.
223
243
PyOpenGLSWIG.&nbsp; The code was basically a huge set of nested
241
261
 
242
262
 
243
263
 
 
264
 
244
265
  </li>
245
266
 
246
267
 
252
273
 
253
274
 
254
275
 
 
276
 
255
277
</ul>
256
278
 
257
279
 
263
285
 
264
286
 
265
287
 
 
288
 
266
289
<p>OpenGL-ctypes is intended to
267
290
become the 3.x release of "PyOpenGL",
268
291
that is, it will eventually replace the 2.x stream as the "standard"
283
306
 
284
307
 
285
308
 
 
309
 
286
310
<h2>Getting the Code</h2>
287
311
 
288
312
 
294
318
 
295
319
 
296
320
 
 
321
 
297
322
<p>OpenGL-ctypes is developed and
298
323
maintained within the PyOpenGL CVS repository.&nbsp; To check out
299
324
the current version of OpenGL-ctypes:</p>
307
332
 
308
333
 
309
334
 
 
335
 
310
336
<pre>cvs -z3 -d:pserver:anonymous@pyopengl.cvs.sourceforge.net:/cvsroot/pyopengl co -P OpenGL-ctypes<br></pre>
311
337
 
312
338
 
318
344
 
319
345
 
320
346
 
 
347
 
321
348
<p>You can install the checkout to your path for further development as
322
349
follows (from the OpenGL-ctypes checkout directory):<br>
323
350
 
330
357
 
331
358
 
332
359
 
 
360
 
333
361
</p>
334
362
 
335
363
 
341
369
 
342
370
 
343
371
 
 
372
 
344
373
<pre>./setup.py develop --install-dir=~/YOUR-WORKING-DIRECTORY-ON-PYTHONPATH-HERE<br></pre>
345
374
 
346
375
 
352
381
 
353
382
 
354
383
 
 
384
 
355
385
<p>As of 3.0.0a3 OpenGL-ctypes is dependant on the <a href="http://peak.telecommunity.com/DevCenter/setuptools">setuptools</a>
356
386
package.&nbsp; You cannot run without the setuptools support, as it is
357
387
used to provide the plugin mechanism used by array data-type plugin
370
400
 
371
401
 
372
402
 
 
403
 
373
404
</p>
374
405
 
375
406
 
381
412
 
382
413
 
383
414
 
 
415
 
384
416
<p>When you make a change, run <code>cvs
385
417
diff</code> on the OpenGL-ctypes
386
418
directory to produce a patch file and upload it to the <a href="https://sourceforge.net/tracker/?group_id=5988&amp;atid=305988">PyOpenGL Patch Tracker</a> as an attachment.&nbsp; I prefer "context" diffs (<code>cvs
397
429
 
398
430
 
399
431
 
 
432
 
400
433
<h2>The Architecture of
401
434
OpenGL-ctypes</h2>
402
435
 
409
442
 
410
443
 
411
444
 
 
445
 
412
446
<p>Here are the loose design goals
413
447
of OpenGL-ctypes:</p>
414
448
 
421
455
 
422
456
 
423
457
 
 
458
 
424
459
<ul>
425
460
 
426
461
 
432
467
 
433
468
 
434
469
 
 
470
 
435
471
  <li>Access to the all of
436
472
OpenGL's functionality</li>
437
473
 
444
480
 
445
481
 
446
482
 
 
483
 
 
484
  
447
485
  
448
486
  
449
487
  
465
503
 
466
504
 
467
505
 
 
506
 
468
507
    <li>Allow access to OpenGL 1.x
469
508
and 2.x functionality</li>
470
509
 
477
516
 
478
517
 
479
518
 
 
519
 
480
520
    <li>Access to modern extensions</li>
481
521
 
482
522
 
488
528
 
489
529
 
490
530
 
 
531
 
 
532
  
491
533
  
492
534
  
493
535
  
509
551
 
510
552
 
511
553
 
 
554
 
512
555
  <li>Backward compatability with
513
556
PyOpenGL code</li>
514
557
 
521
564
 
522
565
 
523
566
 
 
567
 
 
568
  
524
569
  
525
570
  
526
571
  
542
587
 
543
588
 
544
589
 
 
590
 
545
591
    <li>Not a fanatic requirement,
546
592
but I want 90%+ of code to run
547
593
without changes and 99% to run with only minor changes such as one
556
602
 
557
603
 
558
604
 
 
605
 
559
606
    <li>Insulate the PyOpenGL
560
607
developer from the implementation (ctypes) so that code can continue to
561
608
work across multiple implementations</li>
569
616
 
570
617
 
571
618
 
 
619
 
 
620
  
572
621
  
573
622
  
574
623
  
590
639
 
591
640
 
592
641
 
 
642
 
593
643
  <li>Ease of development</li>
594
644
 
595
645
 
601
651
 
602
652
 
603
653
 
 
654
 
 
655
  
604
656
  
605
657
  
606
658
  
622
674
 
623
675
 
624
676
 
 
677
 
625
678
    <li>The whole point of this is
626
679
to make it possible for more people
627
680
to work on the system</li>
635
688
 
636
689
 
637
690
 
 
691
 
 
692
  
638
693
  
639
694
  
640
695
  
656
711
 
657
712
 
658
713
 
 
714
 
659
715
  <li>Play nicely with others</li>
660
716
 
661
717
 
667
723
 
668
724
 
669
725
 
 
726
 
 
727
  
670
728
  
671
729
  
672
730
  
688
746
 
689
747
 
690
748
 
 
749
 
691
750
    <li>Alternate Python
692
751
implementations (PyPy, IronPython)</li>
693
752
 
700
759
 
701
760
 
702
761
 
 
762
 
703
763
    <li>GUI libraries</li>
704
764
 
705
765
 
711
771
 
712
772
 
713
773
 
 
774
 
714
775
    <li>Numeric libraries</li>
715
776
 
716
777
 
722
783
 
723
784
 
724
785
 
 
786
 
725
787
    <li>Threading behaviour</li>
726
788
 
727
789
 
733
795
 
734
796
 
735
797
 
 
798
 
736
799
    <li>Multimedia libraries</li>
737
800
 
738
801
 
744
807
 
745
808
 
746
809
 
 
810
 
 
811
  
747
812
  
748
813
  
749
814
  
765
830
 
766
831
 
767
832
 
 
833
 
768
834
  <li>Flexibility and robustness</li>
769
835
 
770
836
 
776
842
 
777
843
 
778
844
 
 
845
 
 
846
  
779
847
  
780
848
  
781
849
  
797
865
 
798
866
 
799
867
 
 
868
 
800
869
    <li>Graceful degradation in
801
870
the face of missing functionality</li>
802
871
 
809
878
 
810
879
 
811
880
 
 
881
 
812
882
    <li>Ease of debugging</li>
813
883
 
814
884
 
820
890
 
821
891
 
822
892
 
 
893
 
823
894
    <li>Informative error reports</li>
824
895
 
825
896
 
831
902
 
832
903
 
833
904
 
 
905
 
 
906
  
834
907
  
835
908
  
836
909
  
852
925
 
853
926
 
854
927
 
 
928
 
855
929
  <li>Ease of installation</li>
856
930
 
857
931
 
863
937
 
864
938
 
865
939
 
 
940
 
 
941
  
866
942
  
867
943
  
868
944
  
884
960
 
885
961
 
886
962
 
 
963
 
887
964
    <li>Portability (note, we are
888
965
limited to ctypes ported platforms,
889
966
but that should grow faster than we grow, given that ctypes is now part
898
975
 
899
976
 
900
977
 
 
978
 
901
979
    </li>
902
980
 
903
981
 
909
987
 
910
988
 
911
989
 
 
990
 
912
991
    <li>Simplicity of installation
913
992
process (no hacked up distutils!)</li>
914
993
 
921
1000
 
922
1001
 
923
1002
 
 
1003
 
924
1004
    <li>Use of eggs and easy_install</li>
925
1005
 
926
1006
 
932
1012
 
933
1013
 
934
1014
 
 
1015
 
935
1016
    <li>Ability to plug in support for new data-types and the like</li>
936
1017
 
937
1018
 
943
1024
 
944
1025
 
945
1026
 
 
1027
 
 
1028
  
946
1029
  
947
1030
  
948
1031
  
964
1047
 
965
1048
 
966
1049
 
 
1050
 
967
1051
</ul>
968
1052
 
969
1053
 
975
1059
 
976
1060
 
977
1061
 
 
1062
 
978
1063
<h3>Platform Abstraction</h3>
979
1064
 
980
1065
 
986
1071
 
987
1072
 
988
1073
 
 
1074
 
989
1075
<p class="introduction">OpenGL-ctypes
990
1076
is exposing "platform" (Operating
991
1077
System and Hardware) functionality to the Python environment.&nbsp;
1002
1088
 
1003
1089
 
1004
1090
 
 
1091
 
1005
1092
<p>Each platform gets their own <code>OpenGL.platform.baseplatform.BasePlatform</code> subclass.&nbsp; <a href="pydoc/OpenGL.platform.baseplatform.html"><code>OpenGL.platform.baseplatform.BasePlatform</code></a> classes provide:</p>
1006
1093
 
1007
1094
 
1013
1100
 
1014
1101
 
1015
1102
 
 
1103
 
1016
1104
<ul>
1017
1105
 
1018
1106
 
1024
1112
 
1025
1113
 
1026
1114
 
 
1115
 
1027
1116
  <li>ctypes library objects for
1028
1117
GL, GLU, GLUT and possibly GLE. How we
1029
1118
find these libraries, the names of the libraries, flags needed for
1038
1127
 
1039
1128
 
1040
1129
 
 
1130
 
1041
1131
  <li>definition of the ctypes <code>FunctionType</code>
1042
1132
used for
1043
1133
calling functions in the libraries, i.e. what calling convention to use
1053
1143
 
1054
1144
 
1055
1145
 
 
1146
 
1056
1147
  </li>
1057
1148
 
1058
1149
 
1064
1155
 
1065
1156
 
1066
1157
 
 
1158
 
1067
1159
  <li>functions <code>GetCurrentContext()</code>
1068
1160
and <code>CurrentContextIsValid()</code>
1069
1161
to allow code to retrieve and/or test whether we have a current
1081
1173
 
1082
1174
 
1083
1175
 
 
1176
 
1084
1177
  </li>
1085
1178
 
1086
1179
 
1092
1185
 
1093
1186
 
1094
1187
 
 
1188
 
1095
1189
  <li>function <code>getExtensionProcedure(
1096
1190
name )</code> to retrieve
1097
1191
an OpenGL extension function by name</li>
1105
1199
 
1106
1200
 
1107
1201
 
 
1202
 
1108
1203
  <li>function <code>getGLUTFontPointer(
1109
1204
constant )</code> to retrieve
1110
1205
a <code>void *</code>
1120
1215
 
1121
1216
 
1122
1217
 
 
1218
 
1123
1219
  <li>flags <code>HAS_DYNAMIC_EXT</code>
1124
1220
and <code>EXT_DEFINES_PROTO</code>
1125
1221
which tell OpenGL-ctypes whether the platform has the ability to load
1134
1230
 
1135
1231
 
1136
1232
 
 
1233
 
1137
1234
  <li>function safeGetError() to retrieve OpenGL's error state if doing
1138
1235
so would be safe (i.e. we have a valid context or the platform can
1139
 
handle having a call to glGetError when there is no valid context)</li><li>functions/methods
 
1236
handle having a call to glGetError when there is no valid context)</li>
 
1237
  <li>functions/methods
1140
1238
to create/retrieve function pointers from libraries (createBaseFunction
1141
1239
and createExtensionFunction), which insulate us from changes in
1142
1240
ctypes as well as giving us a convenient
1143
 
place to add functionality to any function.<pre><code>def createBaseFunction( <br>&nbsp;&nbsp;&nbsp; functionName, dll=OpenGL, <br>&nbsp;&nbsp;&nbsp; resultType=ctypes.c_int, argTypes=(),<br>&nbsp;&nbsp;&nbsp; doc = None, argNames = (),<br>):</code><br></pre>
1144
 
 
1145
 
 
1146
 
 
1147
 
 
1148
 
 
1149
 
 
1150
 
 
1151
 
 
1152
 
 
1153
 
 
1154
 
<p>and</p>
1155
 
 
1156
 
 
1157
 
 
1158
 
 
1159
 
 
1160
 
 
1161
 
 
1162
 
 
1163
 
 
1164
 
 
1165
 
<pre><code>def createExtensionFunction( <br>    functionName, dll=OpenGL,<br>   resultType=ctypes.c_int, <br>   argTypes=(),<br>        doc = None, argNames = (),<br>):</code></pre>
1166
 
 
1167
 
 
1168
 
 
1169
 
 
1170
 
 
1171
 
 
1172
 
 
1173
 
 
1174
 
 
1175
 
 
1176
 
</li>
 
1241
place to add functionality to any function.
 
1242
    <pre><code>def createBaseFunction( <br>&nbsp;&nbsp;&nbsp; functionName, dll=OpenGL, <br>&nbsp;&nbsp;&nbsp; resultType=ctypes.c_int, argTypes=(),<br>&nbsp;&nbsp;&nbsp; doc = None, argNames = (),<br>):</code><br></pre>
 
1243
 
 
1244
 
 
1245
 
 
1246
 
 
1247
 
 
1248
 
 
1249
 
 
1250
 
 
1251
 
 
1252
 
 
1253
 
 
1254
    <p>and</p>
 
1255
 
 
1256
 
 
1257
 
 
1258
 
 
1259
 
 
1260
 
 
1261
 
 
1262
 
 
1263
 
 
1264
 
 
1265
 
 
1266
    <pre><code>def createExtensionFunction( <br>        functionName, dll=OpenGL,<br>   resultType=ctypes.c_int, <br>   argTypes=(),<br>        doc = None, argNames = (),<br>):</code></pre>
 
1267
 
 
1268
 
 
1269
 
 
1270
 
 
1271
 
 
1272
 
 
1273
 
 
1274
 
 
1275
 
 
1276
 
 
1277
 
 
1278
  </li>
 
1279
 
1177
1280
 
1178
1281
 
1179
1282
 
1195
1298
 
1196
1299
 
1197
1300
 
 
1301
 
1198
1302
<p>New platform implementations are registered in&nbsp;<code>setup.py</code>
1199
1303
using pkgtools entry points. &nbsp;We use the sys.platform and os.name
1200
1304
(in that order of preference) to decide which entry point to load.</p>
1208
1312
 
1209
1313
 
1210
1314
 
 
1315
 
1211
1316
<h3>Autogenerated Wrappers</h3>
1212
1317
 
1213
1318
 
1219
1324
 
1220
1325
 
1221
1326
 
 
1327
 
1222
1328
<p>There are two major wrapper generator systems available for use with
1223
1329
ctypes. &nbsp;Originally OpenGL-ctypes used the ctypes generator module
1224
1330
(based on GCC-XML) to produce its wrappers. &nbsp;We are switching to
1225
1331
using the <code>pyglet/tools/wraptypes</code> module. &nbsp;Extension
1226
1332
modules are currently created via a regex-based generator, eventually
1227
 
we'll switch to using wraptypes for that work as well.</p><h4>wraptypes Generator (new method)</h4><p>The
 
1333
we'll switch to using wraptypes for that work as well.</p>
 
1334
<h4>wraptypes Generator (new method)</h4>
 
1335
<p>The
1228
1336
primary value of wraptypes is that it is easy to install and configure,
1229
1337
and allows for parsing headers which are not "native" to the platform
1230
1338
on which they are being run. &nbsp;The wrapper generator (<code>gengl.py</code>) is not as advanced/finished as the <code>openglgenerator.py</code>
1231
1339
module, but it can generate the platform-specific module quite nicely,
1232
1340
and the underlying code is under active development with a focus on
1233
 
GL-related operations.</p><p>To run this generator, simple check out pyglet's svn repository and add the tools/wraptypes package to your <code>PYTHONPATH</code>, then run the <code>src/gengl.py</code> module in PyOpenGL's source tree.</p><h4>ctypes Wrapper Generator (old method)</h4><p>ctypes includes a mechanism
 
1341
GL-related operations.</p>
 
1342
<p>To run this generator, simple check out pyglet's svn repository and add the tools/wraptypes package to your <code>PYTHONPATH</code>, then run the <code>src/gengl.py</code> module in PyOpenGL's source tree.</p>
 
1343
<h4>ctypes Wrapper Generator (old method)</h4>
 
1344
<p>ctypes includes a mechanism
1234
1345
based on GCC-XML which will autogenerate
1235
1346
wrappers for many C libraries. OpenGL-ctypes uses an
1236
1347
extended&nbsp;version of this autogenerator (in the src subdirectory of
1239
1350
 
1240
1351
 
1241
1352
 
 
1353
 
1242
1354
<p>The generator also produces "annotations" modules in each of the
1243
1355
raw.* packages. &nbsp;These contain calls which wrap the base functions
1244
1356
in size-of-array-aware wrappers. &nbsp;The constants from the module
1247
1359
 
1248
1360
 
1249
1361
 
 
1362
 
1250
1363
<p>Much of the API for the core libraries can be
1251
1364
used
1252
1365
as-is from the <code>raw</code> packages, so the main package modules
1260
1373
 
1261
1374
 
1262
1375
 
 
1376
 
1263
1377
<h5>Making your own Auto-generated Wrappers</h5>
1264
1378
 
1265
1379
 
1268
1382
 
1269
1383
 
1270
1384
 
 
1385
 
1271
1386
<p>If you want to create new core modules (see below for OpenGL
1272
1387
extension modules), you can use the ctypes_codegen module from ctypes
1273
1388
svn. &nbsp;This module is dependant&nbsp;on having a very up-to-date
1284
1399
 
1285
1400
 
1286
1401
 
 
1402
 
1287
1403
<p>You can check out the ctypeslib project from the Python svn tree like so:</p>
1288
1404
 
1289
1405
 
1292
1408
 
1293
1409
 
1294
1410
 
 
1411
 
1295
1412
<pre>svn co http://svn.python.org/projects/ctypes/trunk ctypes<br>cd ctypes/ctypeslib<br>python setup.py install</pre>
1296
1413
 
1297
1414
 
1303
1420
 
1304
1421
 
1305
1422
 
 
1423
 
1306
1424
<p>To create a new PyOpenGL sub-package, such as one to support your
1307
1425
platform-native GLX work-alike (e.g. WGL or AGL), you first create an
1308
1426
XML description of your library. &nbsp;Here's an example:</p>
1313
1431
 
1314
1432
 
1315
1433
 
 
1434
 
1316
1435
<pre>python ~/site-packages/ctypes_codegen/h2xml.py /usr/include/GL/glx.h -o glx.xml -c</pre>
1317
1436
 
1318
1437
 
1321
1440
 
1322
1441
 
1323
1442
 
 
1443
 
1324
1444
<p>which produces an XML file in your local directory (here glx.xml). &nbsp;The <code>-c</code>
1325
1445
flag tells GCC-XML to attempt to include preprocessor definitions in
1326
1446
the XML file, which is normally desirable for GL-related systems, as
1332
1452
 
1333
1453
 
1334
1454
 
 
1455
 
1335
1456
<p>Once we have the XML file, we need to turn it into Python source files. &nbsp;The <code>src/generateraw.py</code>
1336
1457
script in the OpenGL-ctypes source distribution is an example of how to
1337
1458
create new wrappers.&nbsp; Keep in mind that the output here is only
1345
1466
 
1346
1467
 
1347
1468
 
 
1469
 
1348
1470
<p class="technical">Autogeneration has gone through many revisions
1349
1471
over the course of the project. &nbsp;The newest version requires a
1350
1472
heavily restructured version of the ctypes codegenerator module to work.</p>
1351
1473
 
1352
1474
 
1353
1475
 
 
1476
 
1354
1477
<h4>OpenGL Extension Generation</h4>
1355
1478
 
1356
1479
 
1359
1482
 
1360
1483
 
1361
1484
 
 
1485
 
1362
1486
<p>Unlike the core modules,
1363
1487
extension modules are auto-generated using
1364
1488
a low-level hack that downloads the OpenGL extension registry's current
1376
1500
 
1377
1501
 
1378
1502
 
 
1503
 
1379
1504
<p class="technical">The
1380
1505
OpenGL extension definitions in the <code>glext.h</code>
1381
1506
header are split into two parts, a macro which retrieves the pointer to
1392
1517
 
1393
1518
 
1394
1519
 
 
1520
 
1395
1521
<p class="technical">A consequence of this approach is that
1396
1522
OpenGL-ctypes can remain up-to-date for OpenGL extensions.&nbsp;
1397
1523
Producing the raw versions of all new extensions is normally just a
1406
1532
 
1407
1533
 
1408
1534
 
 
1535
 
1409
1536
</p>
1410
1537
 
1411
1538
 
1417
1544
 
1418
1545
 
1419
1546
 
 
1547
 
1420
1548
<p>glGet() output arrays are handled specially by the
1421
1549
auto-generation.&nbsp; It produces calls which register constants
1422
1550
against array sizes so that the glGet* family of calls can return the
1434
1562
 
1435
1563
 
1436
1564
 
 
1565
 
1437
1566
<p>The autogeneration process also attempts to copy the "Overview"
1438
1567
section of the specification for each module into the docstring of the
1439
1568
module, so that users and coders can readily identify the purpose of
1448
1577
 
1449
1578
 
1450
1579
 
 
1580
 
1451
1581
<p>The extension modules are
1452
1582
written as a single file, with the code
1453
1583
for the auto-generated material placed above a comment line which
1462
1592
 
1463
1593
 
1464
1594
 
 
1595
 
1465
1596
<pre>### DO NOT EDIT above the line "END AUTOGENERATED SECTION" below!<br>...<br>### END AUTOGENERATED SECTION</pre>
1466
1597
 
1467
1598
 
1473
1604
 
1474
1605
 
1475
1606
 
 
1607
 
1476
1608
<p>Customisations of the extension
1477
1609
are done after the auto-generated
1478
1610
section.&nbsp; This (single file approach) is done mostly to reduce
1489
1621
 
1490
1622
 
1491
1623
 
 
1624
 
1492
1625
<p class="technical">It is
1493
1626
expected and encouraged that users will hack
1494
1627
on an extension module they care about to make it more Pythonic and
1503
1636
 
1504
1637
 
1505
1638
 
 
1639
 
1506
1640
<p>If you remove the autogenerated
1507
1641
comment then further autogeneration
1508
1642
passes will not process the module, keep in mind, however, that
1518
1652
 
1519
1653
 
1520
1654
 
 
1655
 
1521
1656
<h3>Converters and Wrappers</h3>
1522
1657
 
1523
1658
 
1529
1664
 
1530
1665
 
1531
1666
 
 
1667
 
1532
1668
<p>When a method cannot use the
1533
1669
autogenerated ctypes wrapper as-is, we
1534
1670
normally fall back to the <code><a href="pydoc/OpenGL.wrapper.html">OpenGL.wrapper</a>.Wrapper</code>
1547
1683
 
1548
1684
 
1549
1685
 
 
1686
 
1550
1687
<p class="technical">This
1551
1688
approach will seem familiar to those who have
1552
1689
looked at the source code generated by systems such as SWIG.&nbsp;
1564
1701
 
1565
1702
 
1566
1703
 
 
1704
 
1567
1705
<p>In some cases it's just easier
1568
1706
to code up a custom wrapper function
1569
1707
that uses raw ctypes.&nbsp; We can do so without a problem simply
1579
1717
 
1580
1718
 
1581
1719
 
 
1720
 
1582
1721
<h4>Wrapper Objects</h4>
1583
1722
 
1584
1723
 
1590
1729
 
1591
1730
 
1592
1731
 
 
1732
 
1593
1733
<p>The stages in the Wrapper call
1594
1734
are as follows:</p>
1595
1735
 
1602
1742
 
1603
1743
 
1604
1744
 
 
1745
 
1605
1746
<ol>
1606
1747
 
1607
1748
 
1613
1754
 
1614
1755
 
1615
1756
 
 
1757
 
1616
1758
  <li>pyConverters -- accept (or
1617
1759
suppress) incoming Python arguments</li>
1618
1760
 
1625
1767
 
1626
1768
 
1627
1769
 
 
1770
 
 
1771
  
1628
1772
  
1629
1773
  
1630
1774
  
1646
1790
 
1647
1791
 
1648
1792
 
 
1793
 
1649
1794
    <li>Used to convert a Python
1650
1795
argument to a type which is compatible
1651
1796
with the expected data-type</li>
1659
1804
 
1660
1805
 
1661
1806
 
 
1807
 
1662
1808
    <li>Can be used to eliminate
1663
1809
an argument from the argument list by
1664
1810
passing no function, this is useful when we want to imply an argument
1673
1819
 
1674
1820
 
1675
1821
 
 
1822
 
 
1823
  
1676
1824
  
1677
1825
  
1678
1826
  
1694
1842
 
1695
1843
 
1696
1844
 
 
1845
 
1697
1846
  <li>cConverters -- pull
1698
1847
C-compatible argument out of the Python
1699
1848
argument list</li>
1707
1856
 
1708
1857
 
1709
1858
 
 
1859
 
 
1860
  
1710
1861
  
1711
1862
  
1712
1863
  
1728
1879
 
1729
1880
 
1730
1881
 
 
1882
 
1731
1883
    <li>Looks at the whole set of
1732
1884
Python argument and produces a 1:1
1733
1885
argument list of Python objects for the ctypes call</li>
1741
1893
 
1742
1894
 
1743
1895
 
 
1896
 
 
1897
  
1744
1898
  
1745
1899
  
1746
1900
  
1762
1916
 
1763
1917
 
1764
1918
 
 
1919
 
1765
1920
  <li>cResolvers -- take the
1766
1921
C-compatible Python objects and turn them
1767
1922
into the low-level data-type required by the ctypes call</li>
1775
1930
 
1776
1931
 
1777
1932
 
 
1933
 
1778
1934
  <li>ctypes call, (with error
1779
1935
checking, errors are annotated with the
1780
1936
arguments used during the call)</li>
1788
1944
 
1789
1945
 
1790
1946
 
 
1947
 
1791
1948
  <li>storeValues -- called to
1792
1949
store a C-compatible Python object, for
1793
1950
instance to prevent garbage collection of an array that is in-use</li>
1801
1958
 
1802
1959
 
1803
1960
 
 
1961
 
1804
1962
  <li>returnValues -- determines
1805
1963
what result is required from the
1806
1964
wrapped function</li>
1814
1972
 
1815
1973
 
1816
1974
 
 
1975
 
1817
1976
</ol>
1818
1977
 
1819
1978
 
1825
1984
 
1826
1985
 
1827
1986
 
 
1987
 
1828
1988
<p>Of particular interest is the method <code>wrapper.Wrapper.setOutput</code>
1829
1989
which allows you to generate output arrays for a function using a
1830
1990
passed-in size tuple, dictionary or function to determine the
1841
2001
 
1842
2002
 
1843
2003
 
 
2004
 
1844
2005
<h4>Converters</h4>
1845
2006
 
1846
2007
 
1852
2013
 
1853
2014
 
1854
2015
 
 
2016
 
1855
2017
<p>The <a href="pydoc/OpenGL.converters.html"><code>OpenGL.converters</code></a>
1856
2018
module provides a number of conversion "functions" for use with the
1857
2019
wrapper module's Wrapper objects.&nbsp; The idea of these converter
1869
2031
 
1870
2032
 
1871
2033
 
 
2034
 
1872
2035
<h3>Array Handling</h3>
1873
2036
 
1874
2037
 
1880
2043
 
1881
2044
 
1882
2045
 
 
2046
 
1883
2047
<p class="introduction">While
1884
2048
you can do a great deal of work with OpenGL without array operations,
1885
2049
Python's OpenGL interfaces are all fastest when you use array (or
1896
2060
 
1897
2061
 
1898
2062
 
 
2063
 
1899
2064
<p>Perhaps the most complex
1900
2065
mechanisms in OpenGL-ctypes are those which implement the array-based
1901
2066
operations which allow for using low-level blocks of formatted data to
1912
2077
 
1913
2078
 
1914
2079
 
 
2080
 
1915
2081
<p>The array handling
1916
2082
functionality provided within OpenGL-ctypes is localised to the <a href="pydoc/OpenGL.arrays.html"><code>OpenGL.arrays</code></a>
1917
2083
sub-package.&nbsp; Within the package, there are two major classes,
1931
2097
 
1932
2098
 
1933
2099
 
 
2100
 
1934
2101
<h4>ArrayDatatypes</h4>
1935
2102
 
1936
2103
 
1942
2109
 
1943
2110
 
1944
2111
 
 
2112
 
1945
2113
<p>ArrayDatatype classes provide <a href="pydoc/OpenGL.arrays.__init__.html#ArrayDatatype">an
1946
2114
API</a> composed primarily of
1947
2115
classmethods (that is, methods which are called directly on the class,
1958
2126
 
1959
2127
 
1960
2128
 
 
2129
 
1961
2130
<p>Currently we have the following
1962
2131
array types defined:</p>
1963
2132
 
1970
2139
 
1971
2140
 
1972
2141
 
 
2142
 
1973
2143
<ul>
1974
2144
 
1975
2145
 
1981
2151
 
1982
2152
 
1983
2153
 
 
2154
 
1984
2155
  <li>ArrayDatatype</li>
1985
2156
 
1986
2157
 
1992
2163
 
1993
2164
 
1994
2165
 
 
2166
 
 
2167
  
1995
2168
  
1996
2169
  
1997
2170
  
2013
2186
 
2014
2187
 
2015
2188
 
 
2189
 
2016
2190
    <li>Used for generic array
2017
2191
operations</li>
2018
2192
 
2025
2199
 
2026
2200
 
2027
2201
 
 
2202
 
 
2203
  
2028
2204
  
2029
2205
  
2030
2206
  
2046
2222
 
2047
2223
 
2048
2224
 
 
2225
 
2049
2226
  <li>GLclampdArray</li>
2050
2227
 
2051
2228
 
2057
2234
 
2058
2235
 
2059
2236
 
 
2237
 
2060
2238
  <li>GLclampfArray</li>
2061
2239
 
2062
2240
 
2068
2246
 
2069
2247
 
2070
2248
 
 
2249
 
 
2250
  
2071
2251
  
2072
2252
  
2073
2253
  
2089
2269
 
2090
2270
 
2091
2271
 
 
2272
 
2092
2273
    <li>Clamped floating-point
2093
2274
types</li>
2094
2275
 
2101
2282
 
2102
2283
 
2103
2284
 
 
2285
 
 
2286
  
2104
2287
  
2105
2288
  
2106
2289
  
2122
2305
 
2123
2306
 
2124
2307
 
 
2308
 
2125
2309
  <li>GLfloatArray</li>
2126
2310
 
2127
2311
 
2133
2317
 
2134
2318
 
2135
2319
 
 
2320
 
2136
2321
  <li>GLdoubleArray</li>
2137
2322
 
2138
2323
 
2144
2329
 
2145
2330
 
2146
2331
 
 
2332
 
 
2333
  
2147
2334
  
2148
2335
  
2149
2336
  
2165
2352
 
2166
2353
 
2167
2354
 
 
2355
 
2168
2356
    <li>Un-clamped floating-point
2169
2357
types</li>
2170
2358
 
2177
2365
 
2178
2366
 
2179
2367
 
 
2368
 
 
2369
  
2180
2370
  
2181
2371
  
2182
2372
  
2198
2388
 
2199
2389
 
2200
2390
 
 
2391
 
2201
2392
  <li>GLbyteArray</li>
2202
2393
 
2203
2394
 
2209
2400
 
2210
2401
 
2211
2402
 
 
2403
 
2212
2404
  <li>GLcharArray (GLcharARBArray) <br>
2213
2405
 
2214
2406
 
2220
2412
 
2221
2413
 
2222
2414
 
 
2415
 
2223
2416
  </li>
2224
2417
 
2225
2418
 
2231
2424
 
2232
2425
 
2233
2426
 
 
2427
 
2234
2428
  <li>GLubyteArray</li>
2235
2429
 
2236
2430
 
2242
2436
 
2243
2437
 
2244
2438
 
 
2439
 
 
2440
  
2245
2441
  
2246
2442
  
2247
2443
  
2263
2459
 
2264
2460
 
2265
2461
 
 
2462
 
2266
2463
    <li>Character arrays</li>
2267
2464
 
2268
2465
 
2274
2471
 
2275
2472
 
2276
2473
 
 
2474
 
 
2475
  
2277
2476
  
2278
2477
  
2279
2478
  
2295
2494
 
2296
2495
 
2297
2496
 
 
2497
 
2298
2498
  <li>GLshortArray</li>
2299
2499
 
2300
2500
 
2306
2506
 
2307
2507
 
2308
2508
 
 
2509
 
2309
2510
  <li>GLintArray</li>
2310
2511
 
2311
2512
 
2317
2518
 
2318
2519
 
2319
2520
 
 
2521
 
2320
2522
  <li>GLsizeiArray</li>
2321
2523
 
2322
2524
 
2328
2530
 
2329
2531
 
2330
2532
 
 
2533
 
2331
2534
  <li>GLenumArray</li>
2332
2535
 
2333
2536
 
2339
2542
 
2340
2543
 
2341
2544
 
 
2545
 
 
2546
  
2342
2547
  
2343
2548
  
2344
2549
  
2360
2565
 
2361
2566
 
2362
2567
 
 
2568
 
2363
2569
    <li>Integer array types<br>
2364
2570
 
2365
2571
 
2371
2577
 
2372
2578
 
2373
2579
 
 
2580
 
2374
2581
    </li>
2375
2582
 
2376
2583
 
2382
2589
 
2383
2590
 
2384
2591
 
 
2592
 
 
2593
  
2385
2594
  
2386
2595
  
2387
2596
  
2403
2612
 
2404
2613
 
2405
2614
 
 
2615
 
2406
2616
</ul>
2407
2617
 
2408
2618
 
2414
2624
 
2415
2625
 
2416
2626
 
 
2627
 
2417
2628
<p>When you are coding new
2418
2629
OpenGL-ctypes modules, you should always use the ArrayDatatype
2419
2630
interfaces.&nbsp; These interfaces allow us to code generic
2428
2639
 
2429
2640
 
2430
2641
 
 
2642
 
2431
2643
<h4>Format Handlers<br>
2432
2644
 
2433
2645
 
2439
2651
 
2440
2652
 
2441
2653
 
 
2654
 
2442
2655
</h4>
2443
2656
 
2444
2657
 
2450
2663
 
2451
2664
 
2452
2665
 
 
2666
 
2453
2667
<p>Each format handler is
2454
2668
responsible for implementing an API that ArrayDatatypes can use to work
2455
2669
with the Python data-format.&nbsp; Data-formats can support a
2467
2681
 
2468
2682
 
2469
2683
 
 
2684
 
2470
2685
<p>At the moment we have the
2471
2686
following Format Handlers:</p>
2472
2687
 
2479
2694
 
2480
2695
 
2481
2696
 
 
2697
 
2482
2698
<ul>
2483
2699
 
2484
2700
 
2490
2706
 
2491
2707
 
2492
2708
 
 
2709
 
2493
2710
  <li><a href="pydoc/OpenGL.arrays.nones.html"><code>nones.NoneHandler</code></a></li>
2494
2711
 
2495
2712
 
2501
2718
 
2502
2719
 
2503
2720
 
 
2721
 
 
2722
  
2504
2723
  
2505
2724
  
2506
2725
  
2522
2741
 
2523
2742
 
2524
2743
 
 
2744
 
2525
2745
    <li>Supports passing the None
2526
2746
object as an array data-pointer, quite limited in its functionality</li>
2527
2747
 
2534
2754
 
2535
2755
 
2536
2756
 
 
2757
 
2537
2758
    <li>Implemented in Python</li>
2538
2759
 
2539
2760
 
2545
2766
 
2546
2767
 
2547
2768
 
 
2769
 
2548
2770
    <li>registered as: 'nones'</li>
2549
2771
 
2550
2772
 
2556
2778
 
2557
2779
 
2558
2780
 
 
2781
 
 
2782
  
2559
2783
  
2560
2784
  
2561
2785
  
2577
2801
 
2578
2802
 
2579
2803
 
 
2804
 
2580
2805
  <li><a href="pydoc/OpenGL.arrays.numpymodule.html"><code>numpymodule.NumpyHandler</code></a>,
2581
2806
(<a href="pydoc/OpenGL.arrays.numarrays.html"><code>numarrays.NumarrayHandler</code></a>,&nbsp;<a href="pydoc/OpenGL.arrays.numeric.html"><code>numeric.NumericHandler)</code></a><br>
2582
2807
 
2589
2814
 
2590
2815
 
2591
2816
 
 
2817
 
2592
2818
  </li>
2593
2819
 
2594
2820
 
2600
2826
 
2601
2827
 
2602
2828
 
 
2829
 
 
2830
  
2603
2831
  
2604
2832
  
2605
2833
  
2621
2849
 
2622
2850
 
2623
2851
 
 
2852
 
2624
2853
    <li>Full data-format handlers
2625
2854
for the three Numeric Python implementations</li>
2626
2855
 
2633
2862
 
2634
2863
 
2635
2864
 
 
2865
 
2636
2866
    <li>numpy module is
2637
2867
implemented in Python using a stable API</li>
 
2868
 
2638
2869
    <li>Numeric module is implemented in Python using a bit of a hack</li>
 
2870
 
2639
2871
    <li>Numarray currently requires a C extension and, at the
2640
2872
moment, is not built by default</li>
2641
2873
 
2648
2880
 
2649
2881
 
2650
2882
 
 
2883
 
2651
2884
    <li>registered as: 'numpy' and 'numeric' ('numarray')</li>
2652
2885
 
2653
2886
 
2659
2892
 
2660
2893
 
2661
2894
 
 
2895
 
 
2896
  
2662
2897
  
2663
2898
  
2664
2899
  
2680
2915
 
2681
2916
 
2682
2917
 
 
2918
 
2683
2919
  <li><a href="pydoc/OpenGL.arrays.numbers.html"><code>numbers.NumberHandler</code></a></li>
2684
2920
 
2685
2921
 
2691
2927
 
2692
2928
 
2693
2929
 
 
2930
 
 
2931
  
2694
2932
  
2695
2933
  
2696
2934
  
2712
2950
 
2713
2951
 
2714
2952
 
 
2953
 
2715
2954
    <li>Supports passing single
2716
2955
Python integers/floats in as array data-types</li>
2717
2956
 
2724
2963
 
2725
2964
 
2726
2965
 
 
2966
 
2727
2967
    <li>Does not currently support
2728
2968
use for output arguments (since Numeric arrays are currently used for
2729
2969
single-value output arrays)</li>
2737
2977
 
2738
2978
 
2739
2979
 
 
2980
 
2740
2981
    <li>Implemented in Python</li>
2741
2982
 
2742
2983
 
2748
2989
 
2749
2990
 
2750
2991
 
 
2992
 
2751
2993
    <li>registered as: 'numbers'</li>
2752
2994
 
2753
2995
 
2759
3001
 
2760
3002
 
2761
3003
 
 
3004
 
 
3005
  
2762
3006
  
2763
3007
  
2764
3008
  
2780
3024
 
2781
3025
 
2782
3026
 
 
3027
 
2783
3028
  <li><a href="pydoc/OpenGL.arrays.strings.html"><code>strings.StringHandler</code></a></li>
2784
3029
 
2785
3030
 
2791
3036
 
2792
3037
 
2793
3038
 
 
3039
 
 
3040
  
2794
3041
  
2795
3042
  
2796
3043
  
2812
3059
 
2813
3060
 
2814
3061
 
 
3062
 
2815
3063
    <li>Supports using Python
2816
3064
strings as data-sources, no output support</li>
2817
3065
 
2824
3072
 
2825
3073
 
2826
3074
 
 
3075
 
2827
3076
    <li>Implemented in Python (with a bit of a hack in _strings.py)<br>
2828
3077
 
2829
3078
 
2835
3084
 
2836
3085
 
2837
3086
 
 
3087
 
2838
3088
    </li>
2839
3089
 
2840
3090
 
2846
3096
 
2847
3097
 
2848
3098
 
 
3099
 
2849
3100
    <li>registered as: 'strings'</li>
2850
3101
 
2851
3102
 
2857
3108
 
2858
3109
 
2859
3110
 
 
3111
 
 
3112
  
2860
3113
  
2861
3114
  
2862
3115
  
2878
3131
 
2879
3132
 
2880
3133
 
 
3134
 
2881
3135
  <li><a href="pydoc/OpenGL.arrays.ctypesarrays.html">ctypesarrays.CtypesArrayHandler</a>,
2882
3136
    <a href="pydoc/OpenGL.arrays.ctypespointers.html">ctypespointers.CtypesPointerHandler</a></li>
2883
3137
 
2890
3144
 
2891
3145
 
2892
3146
 
 
3147
 
 
3148
  
2893
3149
  
2894
3150
  
2895
3151
  
2911
3167
 
2912
3168
 
2913
3169
 
 
3170
 
2914
3171
    <li>Full data-format handler for ctypes arrays, input-only for
2915
3172
pointers</li>
2916
3173
 
2923
3180
 
2924
3181
 
2925
3182
 
 
3183
 
2926
3184
    <li>Implemented in Python</li>
2927
3185
 
2928
3186
 
2934
3192
 
2935
3193
 
2936
3194
 
 
3195
 
2937
3196
    <li>registered as: 'ctypesarrays','ctypespointers'</li>
2938
3197
 
2939
3198
 
2945
3204
 
2946
3205
 
2947
3206
 
 
3207
 
 
3208
  
2948
3209
  
2949
3210
  
2950
3211
  
2962
3223
 
2963
3224
 
2964
3225
 
 
3226
 
2965
3227
  <li>lists.ListHandler</li>
2966
3228
 
2967
3229
 
2969
3231
 
2970
3232
 
2971
3233
 
 
3234
 
 
3235
  
2972
3236
  
2973
3237
  
2974
3238
  
2982
3246
 
2983
3247
 
2984
3248
 
 
3249
 
2985
3250
    <li>Backup supports for using Python lists/tuples as data-sources if there is no numpy module available</li>
2986
3251
 
2987
3252
 
2989
3254
 
2990
3255
 
2991
3256
 
 
3257
 
2992
3258
    <li>registered as 'lists'</li>
2993
3259
 
2994
3260
 
2996
3262
 
2997
3263
 
2998
3264
 
 
3265
 
 
3266
  
2999
3267
  
3000
3268
  
3001
3269
  
3013
3281
 
3014
3282
 
3015
3283
 
 
3284
 
3016
3285
</ul>
3017
3286
 
3018
3287
 
3024
3293
 
3025
3294
 
3026
3295
 
 
3296
 
3027
3297
<h5>Registering new FormatHandlers</h5>
3028
3298
 
3029
3299
 
3035
3305
 
3036
3306
 
3037
3307
 
3038
 
<p>OpenGL-ctypes uses the setuptools/pkg_resources entry_points API to
3039
 
register FormatHandlers.&nbsp; The format handlers provided in
3040
 
OpenGL-ctypes are all set up by the setupegg.py script.&nbsp; Each
3041
 
binds a name (such as 'numpy' to a FormatHandler sub-class's
3042
 
name).&nbsp; You can register your own FormatHandler sub-class using
3043
 
code similar to this in your project's setuptools setup script:</p>
3044
 
 
3045
 
 
3046
 
 
3047
 
 
3048
 
 
3049
 
 
3050
 
 
3051
 
 
3052
 
 
3053
 
 
3054
 
<pre>from setuptools import setup, find_packages<br>if __name__ == "__main__":<br>      setup(<br>              ...<br>         entry_points = {<br>                    'OpenGL.arrays.formathandler':[<br>                             'numpy = OpenGL.arrays.numpymodule:NumpyHandler',<br>                   ],<br>          },<br>  )<br></pre>
3055
 
 
3056
 
 
3057
 
 
3058
 
 
3059
 
 
3060
 
 
3061
 
 
3062
 
 
3063
 
 
3064
 
 
 
3308
 
 
3309
<p>OpenGL-ctypes uses the simplistic OpenGL.plugins module which allows
 
3310
you to register a plugin instance which defines a class which is to be
 
3311
loaded to handle a given data format.</p>
 
3312
<pre>from OpenGL.plugins import FormatHandler<br>FormatHandler( 'numpy', 'OpenGL.arrays.numpymodule.NumpyHandler', ['numpy.ndarray'] )</pre>
 
3313
<p>The first parameter is just a name used to refer to the plugin.
 
3314
&nbsp;The second is the actual class to load. &nbsp;If there is not
 
3315
third parameter, then the plugin will automatically load. &nbsp;If
 
3316
there is a value, then the value is a&nbsp;list of module.classname
 
3317
values which will be matched against incoming array-parameter values.</p>
3065
3318
<p>OpenGL-ctypes delays resolving the FormatHandler set until the last
3066
3319
possible moment (i.e. the first call is made which requires a
3067
3320
FormatHandler).&nbsp; Any time before this you can use code like this
3078
3331
 
3079
3332
 
3080
3333
 
 
3334
 
3081
3335
<pre>from OpenGL.arrays import formathandler<br>formathandler.FormatHandler.chooseOutput( 'ctypesarrays' )</pre>
3082
3336
 
3083
3337
 
3089
3343
 
3090
3344
 
3091
3345
 
 
3346
 
3092
3347
<p>Where the strings passed are those under which the handler was
3093
3348
registered (see previous section).</p>
3094
3349
 
3101
3356
 
3102
3357
 
3103
3358
 
 
3359
 
3104
3360
<p class="technical">There are currently no C-level extension modules
3105
3361
in OpenGL-ctypes.&nbsp; However, we have (disabled) implementations for
3106
3362
a few format handlers which are C extensions.&nbsp; It should be
3122
3378
 
3123
3379
 
3124
3380
 
 
3381
 
3125
3382
<h3>Image Handling</h3>
3126
3383
 
3127
3384
 
3133
3390
 
3134
3391
 
3135
3392
 
 
3393
 
3136
3394
<p>Most of the complexity of Image
3137
3395
handling is taken care of by the Array Handling functionality, as most
3138
3396
image data-types are simply arrays of data in a given format.&nbsp;
3149
3407
 
3150
3408
 
3151
3409
 
 
3410
 
3152
3411
<p>The <a href="pydoc/OpenGL.images.html"><code>OpenGL.images</code></a>
3153
3412
module has the basic functions and data-tables which allow for
3154
3413
processing image data (both input and output).&nbsp; Eventually we
3164
3423
 
3165
3424
 
3166
3425
 
 
3426
 
3167
3427
<p>The <a href="pydoc/OpenGL.GL.images.html"><code>OpenGL.GL.images</code></a>
3168
3428
module has implementations of the core OpenGL image-manipulation
3169
3429
functions which use the OpenGL.images module.&nbsp; It can serve as
3178
3438
 
3179
3439
 
3180
3440
 
 
3441
 
3181
3442
<h3>Error Handling</h3>
3182
3443
 
3183
3444
 
3189
3450
 
3190
3451
 
3191
3452
 
 
3453
 
3192
3454
<p>As with previous versions of
3193
3455
PyOpenGL, OpenGL-ctypes tries to follow Python's</p>
3194
3456
 
3201
3463
 
3202
3464
 
3203
3465
 
 
3466
 
3204
3467
<p class="introduction">Errors
3205
3468
should never pass silently. </p>
3206
3469
 
3213
3476
 
3214
3477
 
3215
3478
 
 
3479
 
3216
3480
<p>philosophy, rather than
3217
3481
OpenGL's philosophy of always requiring explicit checks for error
3218
3482
conditions.&nbsp; OpenGL-ctypes functions run the function <code>OpenGL.error.glCheckError</code>
3230
3494
 
3231
3495
 
3232
3496
 
 
3497
 
3233
3498
<p>You can override the error-handler, either to provide your own
3234
3499
custom functionality, or to disable checking entirely.&nbsp; For
3235
3500
instance, if you will always have a valid context, you could register
3245
3510
 
3246
3511
 
3247
3512
 
 
3513
 
3248
3514
<pre>from OpenGL import error<br>error.ErrorChecker.registerChecker( myAlternateFunction )</pre>
3249
3515
 
3250
3516
 
3256
3522
 
3257
3523
 
3258
3524
 
 
3525
 
3259
3526
<p>OpenGL-ctypes has a set of
3260
3527
errors defined in the <a href="pydoc/OpenGL.error.html"><code>OpenGL.error</code></a>
3261
3528
module.&nbsp; It can also raise standard Python exceptions, such as
3272
3539
 
3273
3540
 
3274
3541
 
 
3542
 
3275
3543
</p>
3276
3544
 
3277
3545
 
3283
3551
 
3284
3552
 
3285
3553
 
 
3554
 
3286
3555
<p>Wrapper objects catch OpenGL
3287
3556
errors and annotate the error with extra information to make it easier
3288
3557
to debug failures during the wrapping process.</p>
3296
3565
 
3297
3566
 
3298
3567
 
 
3568
 
3299
3569
<h3>Context-specific Data</h3>
3300
3570
 
3301
3571
 
3307
3577
 
3308
3578
 
3309
3579
 
 
3580
 
3310
3581
<p>Because of the way OpenGL and
3311
3582
ctypes handle, for instance, pointers, to array data, it is often
3312
3583
necessary to ensure that a Python data-structure is retained (i.e. not
3325
3596
 
3326
3597
 
3327
3598
 
 
3599
 
3328
3600
<p class="technical">The
3329
3601
key that is used to index the storage array is provided by the platform
3330
3602
module's <code>GetCurrentContext()</code>
3340
3612
 
3341
3613
 
3342
3614
 
 
3615
 
3343
3616
</p>
3344
3617
 
3345
3618
 
3351
3624
 
3352
3625
 
3353
3626
 
 
3627
 
3354
3628
<p>You can store a new value for
3355
3629
the current context with a call to:</p>
3356
3630
 
3363
3637
 
3364
3638
 
3365
3639
 
 
3640
 
3366
3641
<pre>def setValue( constant, value, context=None, weak=False ):<br>     """Set a stored value for the given context"""</pre>
3367
3642
 
3368
3643
 
3374
3649
 
3375
3650
 
3376
3651
 
 
3652
 
3377
3653
<p>You can retrieve the current
3378
3654
value (which will return None if there is no currently set value) with
3379
3655
a call to:</p>
3387
3663
 
3388
3664
 
3389
3665
 
 
3666
 
3390
3667
<pre>def getValue( constant, context = None ):<br>      """Get a stored value for the given constant"""</pre>
3391
3668
 
3392
3669
 
3398
3675
 
3399
3676
 
3400
3677
 
 
3678
 
3401
3679
<p>Lastly, you can delete any
3402
3680
currently set value with:</p>
3403
3681
 
3410
3688
 
3411
3689
 
3412
3690
 
 
3691
 
3413
3692
<pre>def delValue( constant, context=None ):<br>        """Delete the specified value for the given context"""</pre>
3414
3693
 
3415
3694
 
3421
3700
 
3422
3701
 
3423
3702
 
 
3703
 
3424
3704
<p>which will return a boolean
3425
3705
telling you whether an existing value was found.</p>
3426
3706
 
3433
3713
 
3434
3714
 
3435
3715
 
 
3716
 
3436
3717
<p class="technical">Keep
3437
3718
in mind that you must either explicitly clear out each stored value or
3438
3719
explicitly clear out the stored data with a call to <code>OpenGL.contextdata.cleanupContext</code>
3447
3728
 
3448
3729
 
3449
3730
 
 
3731
 
3450
3732
<h3>Extensions</h3>
3451
3733
 
3452
3734
 
3458
3740
 
3459
3741
 
3460
3742
 
 
3743
 
3461
3744
<p>The OpenGL extension mechanism
3462
3745
is quite well developed, with most new functionality appearing as an
3463
3746
extension before it migrates into the OpenGL core.&nbsp; There are
3474
3757
 
3475
3758
 
3476
3759
 
 
3760
 
3477
3761
<p>A few of the largest
3478
3762
extensions, such as the <a href="pydoc/OpenGL.GL.ARB.shader_objects_new.html"><code>GL.ARB.shader_object</code></a>
3479
3763
or <a href="pydoc/OpenGL.GL.ARB.vertex_buffer_object.html"><code>GL.ARB.vertex_buffer_object</code></a>
3490
3774
 
3491
3775
 
3492
3776
 
 
3777
 
3493
3778
<h3>Tkinter (Legacy GUI) Togl
3494
3779
Support</h3>
3495
3780
 
3502
3787
 
3503
3788
 
3504
3789
 
 
3790
 
3505
3791
<p>We have included the Python
3506
3792
wrapper for the Tk Togl widget in the OpenGL-ctypes package.&nbsp;
3507
3793
We do not, however, currently include the Togl widget itself.&nbsp;
3519
3805
 
3520
3806
 
3521
3807
 
 
3808
 
3522
3809
<p class="technical">Historically,
3523
3810
Togl support was one of the most complex and error-prone aspects of the
3524
3811
PyOpenGL installation procedure.&nbsp; Although there are lots of
3536
3823
 
3537
3824
 
3538
3825
 
 
3826
 
3539
3827
<h2>Todo</h2>
3540
3828
 
3541
3829
 
3547
3835
 
3548
3836
 
3549
3837
 
 
3838
 
3550
3839
<p>OpenGL-ctypes is still far from finished.&nbsp; Here is a (partial)
3551
3840
list of tasks still needing to be completed, I'll add more here as I
3552
3841
discover it:</p>
3560
3849
 
3561
3850
 
3562
3851
 
3563
 
<ul><li>Extension development support<br>
 
3852
 
 
3853
<ul>
 
3854
  <li>Extension development support<br>
 
3855
 
3564
3856
 
3565
3857
 
3566
3858
 
3582
3874
 
3583
3875
 
3584
3876
 
 
3877
 
 
3878
  
3585
3879
  
3586
3880
  
3587
3881
  
3603
3897
 
3604
3898
 
3605
3899
 
 
3900
 
3606
3901
    <li>We need more elegant and stable APIs for implementing
3607
3902
OpenGL
3608
3903
extensions, particularly ones that have far-reaching consequences, that
3617
3912
 
3618
3913
 
3619
3914
 
 
3915
 
 
3916
  
3620
3917
  
3621
3918
  
3622
3919
  
3638
3935
 
3639
3936
 
3640
3937
 
 
3938
 
3641
3939
  <li>Major extensions needing lots of love<br>
3642
3940
 
3643
3941
 
3649
3947
 
3650
3948
 
3651
3949
 
 
3950
 
3652
3951
  </li>
3653
3952
 
3654
3953
 
3660
3959
 
3661
3960
 
3662
3961
 
 
3962
 
 
3963
  
3663
3964
  
3664
3965
  
3665
3966
  
3681
3982
 
3682
3983
 
3683
3984
 
 
3985
 
3684
3986
    <li>ARB vertex buffer object</li>
3685
3987
 
3686
3988
 
3692
3994
 
3693
3995
 
3694
3996
 
 
3997
 
3695
3998
    <li>ARB imaging</li>
3696
3999
 
3697
4000
 
3703
4006
 
3704
4007
 
3705
4008
 
 
4009
 
3706
4010
    <li>ARB vertex/fragment shaders, shader objects (though they appear to be basically functional)</li>
3707
4011
 
3708
4012
 
3714
4018
 
3715
4019
 
3716
4020
 
 
4021
 
 
4022
  
3717
4023
  
3718
4024
  
3719
4025
  
3735
4041
 
3736
4042
 
3737
4043
 
 
4044
 
3738
4045
  <li>Wrapping of OpenGL 1.4, 1.5 and 2.0 support</li>
3739
4046
 
3740
4047
 
3746
4053
 
3747
4054
 
3748
4055
 
 
4056
 
 
4057
  
3749
4058
  
3750
4059
  
3751
4060
  
3767
4076
 
3768
4077
 
3769
4078
 
 
4079
 
3770
4080
    <li>Mostly just mechanical stuff wrapping array-handling code, doing image-transfer operations or the like</li>
3771
4081
 
3772
4082
 
3778
4088
 
3779
4089
 
3780
4090
 
 
4091
 
 
4092
  
3781
4093
  
3782
4094
  
3783
4095
  
3799
4111
 
3800
4112
 
3801
4113
 
 
4114
 
3802
4115
  <li>Documentation</li>
3803
4116
 
3804
4117
 
3810
4123
 
3811
4124
 
3812
4125
 
 
4126
 
 
4127
  
3813
4128
  
3814
4129
  
3815
4130
  
3831
4146
 
3832
4147
 
3833
4148
 
 
4149
 
3834
4150
    <li>Need docstring cleanup and critique</li>
3835
4151
 
3836
4152
 
3842
4158
 
3843
4159
 
3844
4160
 
 
4161
 
 
4162
  
3845
4163
  
3846
4164
  
3847
4165
  
3863
4181
 
3864
4182
 
3865
4183
 
 
4184
 
 
4185
  
3866
4186
  
3867
4187
  
3868
4188
  
3884
4204
 
3885
4205
 
3886
4206
 
 
4207
 
3887
4208
    <li>Re-integrate with the OpenGL, GLU and GLUT documentation set (from
3888
4209
PyOpenGL)</li>
3889
4210
 
3896
4217
 
3897
4218
 
3898
4219
 
 
4220
 
3899
4221
    <li>User-oriented documentation</li>
3900
4222
 
3901
4223
 
3907
4229
 
3908
4230
 
3909
4231
 
3910
 
  
3911
 
  
3912
 
  
3913
 
  
3914
 
  
3915
 
  
3916
 
  
3917
 
  
3918
 
  
3919
 
  
3920
 
  </ul><li>Testing</li>
3921
 
 
3922
 
 
3923
 
 
3924
 
 
3925
 
 
3926
 
 
3927
 
 
3928
 
 
3929
 
 
3930
 
 
 
4232
 
 
4233
  
 
4234
  
 
4235
  
 
4236
  
 
4237
  
 
4238
  
 
4239
  
 
4240
  
 
4241
  
 
4242
  
 
4243
  
 
4244
  </ul>
 
4245
  <li>Testing</li>
 
4246
 
 
4247
 
 
4248
 
 
4249
 
 
4250
 
 
4251
 
 
4252
 
 
4253
 
 
4254
 
 
4255
 
 
4256
 
 
4257
  
3931
4258
  
3932
4259
  
3933
4260
  
3949
4276
 
3950
4277
 
3951
4278
 
 
4279
 
3952
4280
    <li>Need to test with lots of PyOpenGL code to either eliminate or
3953
4281
document incompatibilities</li>
3954
4282
 
3961
4289
 
3962
4290
 
3963
4291
 
 
4292
 
 
4293
  
3964
4294
  
3965
4295
  
3966
4296
  
3982
4312
 
3983
4313
 
3984
4314
 
3985
 
</ul><p class="footer">&nbsp;
 
4315
 
 
4316
</ul>
 
4317
<p class="footer">&nbsp;
3986
4318
<a href="http://pyopengl.sourceforge.net/"><img alt="PyOpenGL" src="images/pyopengl_icon.jpg" style="border: 0px solid ; width: 32px; height: 32px;" align="middle"></a>A
3987
4319
SourceForge Open-Source project: <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=5988&amp;type=1" style="border: 0px solid ; width: 88px; height: 31px;" alt="SourceForge" align="middle"></a></p>
3988
4320
 
3995
4327
 
3996
4328
 
3997
4329
 
3998
 
</body></html>
 
 
b'\\ No newline at end of file'
 
4330
 
 
4331
</body>
 
4332
</html>