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