blob: adae10eb09b072de73936eebe189365690cc2c5b [file] [log] [blame]
Roger E. Masse6da29531996-12-24 19:36:07 +00001#! /usr/bin/env python
2"""Very simple test script for the SGI gl library extension module
3 taken mostly from the documentation.
4 Roger E. Masse
5"""
Barry Warsaw408b6d32002-07-30 23:27:12 +00006from test.test_support import verbose, TestSkipped
Roger E. Masse6da29531996-12-24 19:36:07 +00007import gl, GL, time
8
9glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
10'__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf',
11'arcfi', 'arcfs', 'arci', 'arcs', 'attachcursor', 'backbuffer',
12'backface', 'bbox2', 'bbox2i', 'bbox2s', 'bgnclosedline', 'bgnline',
13'bgnpoint', 'bgnpolygon', 'bgnsurface', 'bgntmesh', 'bgntrim',
14'blankscreen', 'blanktime', 'blendfunction', 'blink', 'c3f', 'c3i',
15'c3s', 'c4f', 'c4i', 'c4s', 'callobj', 'charstr', 'chunksize', 'circ',
16'circf', 'circfi', 'circfs', 'circi', 'circs', 'clear',
17'clearhitcode', 'clkoff', 'clkon', 'closeobj', 'cmode', 'cmov',
18'cmov2', 'cmov2i', 'cmov2s', 'cmovi', 'cmovs', 'color', 'colorf',
19'compactify', 'concave', 'cpack', 'crv', 'crvn', 'curorigin',
20'cursoff', 'curson', 'curstype', 'curvebasis', 'curveit',
21'curveprecision', 'cyclemap', 'czclear', 'defbasis', 'defcursor',
22'deflinestyle', 'delobj', 'deltag', 'depthcue', 'devport', 'dglclose',
23'dglopen', 'dither', 'dopup', 'doublebuffer', 'draw', 'draw2',
24'draw2i', 'draw2s', 'drawi', 'drawmode', 'draws', 'editobj',
25'endclosedline', 'endfullscrn', 'endline', 'endpick', 'endpoint',
26'endpolygon', 'endpupmode', 'endselect', 'endsurface', 'endtmesh',
27'endtrim', 'finish', 'font', 'foreground', 'freepup', 'frontbuffer',
28'fudge', 'fullscrn', 'gRGBcolor', 'gRGBmask', 'gammaramp', 'gbegin',
29'gconfig', 'genobj', 'gentag', 'getbackface', 'getbuffer',
30'getbutton', 'getcmmode', 'getcolor', 'getcpos', 'getcursor',
31'getdcm', 'getdepth', 'getdescender', 'getdisplaymode', 'getdrawmode',
32'getfont', 'getgdesc', 'getgpos', 'getheight', 'gethitcode',
33'getlsbackup', 'getlsrepeat', 'getlstyle', 'getlwidth', 'getmap',
34'getmatrix', 'getmcolor', 'getmmode', 'getmonitor',
35'getnurbsproperty', 'getopenobj', 'getorigin', 'getothermonitor',
36'getpattern', 'getplanes', 'getport', 'getresetls', 'getscrmask',
37'getshade', 'getsize', 'getsm', 'gettp', 'getvaluator', 'getvideo',
38'getviewport', 'getwritemask', 'getzbuffer', 'gewrite', 'gflush',
39'ginit', 'glcompat', 'greset', 'gselect', 'gsync', 'gversion',
40'iconsize', 'icontitle', 'imakebackground', 'initnames', 'ismex',
41'isobj', 'isqueued', 'istag', 'keepaspect', 'lRGBrange', 'lampoff',
42'lampon', 'linesmooth', 'linewidth', 'lmbind', 'lmcolor', 'lmdef',
43'loadmatrix', 'loadname', 'logicop', 'lookat', 'lrectread',
44'lrectwrite', 'lsbackup', 'lsetdepth', 'lshaderange', 'lsrepeat',
45'makeobj', 'maketag', 'mapcolor', 'mapw', 'mapw2', 'maxsize',
46'minsize', 'mmode', 'move', 'move2', 'move2i', 'move2s', 'movei',
47'moves', 'multimap', 'multmatrix', 'n3f', 'newpup', 'newtag',
48'noborder', 'noise', 'noport', 'normal', 'nurbscurve', 'nurbssurface',
49'nvarray', 'objdelete', 'objinsert', 'objreplace', 'onemap', 'ortho',
50'ortho2', 'overlay', 'packrect', 'pagecolor', 'pagewritemask',
51'passthrough', 'patch', 'patchbasis', 'patchcurves', 'patchprecision',
52'pclos', 'pdr', 'pdr2', 'pdr2i', 'pdr2s', 'pdri', 'pdrs',
53'perspective', 'pick', 'picksize', 'pixmode', 'pmv', 'pmv2', 'pmv2i',
54'pmv2s', 'pmvi', 'pmvs', 'pnt', 'pnt2', 'pnt2i', 'pnt2s', 'pnti',
55'pnts', 'pntsmooth', 'polarview', 'polf', 'polf2', 'polf2i', 'polf2s',
56'polfi', 'polfs', 'poly', 'poly2', 'poly2i', 'poly2s', 'polyi',
57'polys', 'popattributes', 'popmatrix', 'popname', 'popviewport',
58'prefposition', 'prefsize', 'pupmode', 'pushattributes', 'pushmatrix',
59'pushname', 'pushviewport', 'pwlcurve', 'qdevice', 'qenter', 'qgetfd',
60'qread', 'qreset', 'qtest', 'rcrv', 'rcrvn', 'rdr', 'rdr2', 'rdr2i',
61'rdr2s', 'rdri', 'rdrs', 'readdisplay', 'readsource', 'rect',
62'rectcopy', 'rectf', 'rectfi', 'rectfs', 'recti', 'rects', 'rectzoom',
63'resetls', 'reshapeviewport', 'ringbell', 'rmv', 'rmv2', 'rmv2i',
64'rmv2s', 'rmvi', 'rmvs', 'rot', 'rotate', 'rpatch', 'rpdr', 'rpdr2',
65'rpdr2i', 'rpdr2s', 'rpdri', 'rpdrs', 'rpmv', 'rpmv2', 'rpmv2i',
66'rpmv2s', 'rpmvi', 'rpmvs', 'sbox', 'sboxf', 'sboxfi', 'sboxfs',
67'sboxi', 'sboxs', 'scale', 'screenspace', 'scrmask', 'setbell',
68'setcursor', 'setdepth', 'setlinestyle', 'setmap', 'setmonitor',
69'setnurbsproperty', 'setpattern', 'setpup', 'setshade', 'setvaluator',
70'setvideo', 'shademodel', 'shaderange', 'singlebuffer', 'smoothline',
71'spclos', 'splf', 'splf2', 'splf2i', 'splf2s', 'splfi', 'splfs',
72'stepunit', 'strwidth', 'subpixel', 'swapbuffers', 'swapinterval',
73'swaptmesh', 'swinopen', 'textcolor', 'textinit', 'textport',
74'textwritemask', 'tie', 'tpoff', 'tpon', 'translate', 'underlay',
75'unpackrect', 'unqdevice', 'v2d', 'v2f', 'v2i', 'v2s', 'v3d', 'v3f',
76'v3i', 'v3s', 'v4d', 'v4f', 'v4i', 'v4s', 'varray', 'videocmd',
77'viewport', 'vnarray', 'winattach', 'winclose', 'winconstraints',
78'windepth', 'window', 'winget', 'winmove', 'winopen', 'winpop',
79'winposition', 'winpush', 'winset', 'wintitle', 'wmpack', 'writemask',
80'writepixels', 'xfpt', 'xfpt2', 'xfpt2i', 'xfpt2s', 'xfpt4', 'xfpt4i',
81'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction',
82'zsource', 'zwritemask']
83
84def main():
85 # insure that we at least have an X display before continuing.
86 import os
87 try:
Guido van Rossum41360a41998-03-26 19:42:58 +000088 display = os.environ['DISPLAY']
Roger E. Masse6da29531996-12-24 19:36:07 +000089 except:
Thomas Woutersb9fa0a82000-08-04 13:34:43 +000090 raise TestSkipped, "No $DISPLAY -- skipping gl test"
Roger E. Masse6da29531996-12-24 19:36:07 +000091
92 # touch all the attributes of gl without doing anything
93 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +000094 print('Touching gl module attributes...')
Roger E. Masse6da29531996-12-24 19:36:07 +000095 for attr in glattrs:
Guido van Rossum41360a41998-03-26 19:42:58 +000096 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +000097 print('touching: ', attr)
Guido van Rossum41360a41998-03-26 19:42:58 +000098 getattr(gl, attr)
Roger E. Masse6da29531996-12-24 19:36:07 +000099
100 # create a small 'Crisscross' window
101 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000102 print('Creating a small "CrissCross" window...')
103 print('foreground')
Roger E. Masse6da29531996-12-24 19:36:07 +0000104 gl.foreground()
105 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000106 print('prefposition')
Roger E. Masse6da29531996-12-24 19:36:07 +0000107 gl.prefposition(500, 900, 500, 900)
108 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000109 print('winopen "CrissCross"')
Roger E. Masse6da29531996-12-24 19:36:07 +0000110 w = gl.winopen('CrissCross')
111 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000112 print('clear')
Guido van Rossum9d1a02c1997-01-03 22:42:08 +0000113 gl.clear()
114 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000115 print('ortho2')
Roger E. Masse6da29531996-12-24 19:36:07 +0000116 gl.ortho2(0.0, 400.0, 0.0, 400.0)
117 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000118 print('color WHITE')
Roger E. Masse6da29531996-12-24 19:36:07 +0000119 gl.color(GL.WHITE)
120 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000121 print('color RED')
Roger E. Masse6da29531996-12-24 19:36:07 +0000122 gl.color(GL.RED)
123 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000124 print('bgnline')
Roger E. Masse6da29531996-12-24 19:36:07 +0000125 gl.bgnline()
126 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000127 print('v2f')
Roger E. Masse6da29531996-12-24 19:36:07 +0000128 gl.v2f(0.0, 0.0)
129 gl.v2f(400.0, 400.0)
130 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000131 print('endline')
Roger E. Masse6da29531996-12-24 19:36:07 +0000132 gl.endline()
133 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000134 print('bgnline')
Roger E. Masse6da29531996-12-24 19:36:07 +0000135 gl.bgnline()
Roger E. Masse6da29531996-12-24 19:36:07 +0000136 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000137 print('v2i')
Guido van Rossum9d1a02c1997-01-03 22:42:08 +0000138 gl.v2i(400, 0)
139 gl.v2i(0, 400)
140 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000141 print('endline')
Roger E. Masse6da29531996-12-24 19:36:07 +0000142 gl.endline()
Guido van Rossum9d1a02c1997-01-03 22:42:08 +0000143 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000144 print('Displaying window for 2 seconds...')
Guido van Rossum9d1a02c1997-01-03 22:42:08 +0000145 time.sleep(2)
146 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +0000147 print('winclose')
Roger E. Masse6da29531996-12-24 19:36:07 +0000148 gl.winclose(w)
Fred Drake004d5e62000-10-23 17:22:08 +0000149
Roger E. Masse6da29531996-12-24 19:36:07 +0000150main()