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