0001 #! /usr/bin/env python 0002 """Very simple test script for the SGI gl library extension module 0003 taken mostly from the documentation. 0004 Roger E. Masse 0005 """ 0006 from test.test_support import verbose, TestSkipped 0007 import gl, GL, time 0008 0009 glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask', 0010 '__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf', 0011 'arcfi', 'arcfs', 'arci', 'arcs', 'attachcursor', 'backbuffer', 0012 'backface', 'bbox2', 'bbox2i', 'bbox2s', 'bgnclosedline', 'bgnline', 0013 'bgnpoint', 'bgnpolygon', 'bgnsurface', 'bgntmesh', 'bgntrim', 0014 'blankscreen', 'blanktime', 'blendfunction', 'blink', 'c3f', 'c3i', 0015 'c3s', 'c4f', 'c4i', 'c4s', 'callobj', 'charstr', 'chunksize', 'circ', 0016 'circf', 'circfi', 'circfs', 'circi', 'circs', 'clear', 0017 'clearhitcode', 'clkoff', 'clkon', 'closeobj', 'cmode', 'cmov', 0018 'cmov2', 'cmov2i', 'cmov2s', 'cmovi', 'cmovs', 'color', 'colorf', 0019 'compactify', 'concave', 'cpack', 'crv', 'crvn', 'curorigin', 0020 'cursoff', 'curson', 'curstype', 'curvebasis', 'curveit', 0021 'curveprecision', 'cyclemap', 'czclear', 'defbasis', 'defcursor', 0022 'deflinestyle', 'delobj', 'deltag', 'depthcue', 'devport', 'dglclose', 0023 'dglopen', 'dither', 'dopup', 'doublebuffer', 'draw', 'draw2', 0024 'draw2i', 'draw2s', 'drawi', 'drawmode', 'draws', 'editobj', 0025 'endclosedline', 'endfullscrn', 'endline', 'endpick', 'endpoint', 0026 'endpolygon', 'endpupmode', 'endselect', 'endsurface', 'endtmesh', 0027 'endtrim', 'finish', 'font', 'foreground', 'freepup', 'frontbuffer', 0028 'fudge', 'fullscrn', 'gRGBcolor', 'gRGBmask', 'gammaramp', 'gbegin', 0029 'gconfig', 'genobj', 'gentag', 'getbackface', 'getbuffer', 0030 'getbutton', 'getcmmode', 'getcolor', 'getcpos', 'getcursor', 0031 'getdcm', 'getdepth', 'getdescender', 'getdisplaymode', 'getdrawmode', 0032 'getfont', 'getgdesc', 'getgpos', 'getheight', 'gethitcode', 0033 'getlsbackup', 'getlsrepeat', 'getlstyle', 'getlwidth', 'getmap', 0034 'getmatrix', 'getmcolor', 'getmmode', 'getmonitor', 0035 'getnurbsproperty', 'getopenobj', 'getorigin', 'getothermonitor', 0036 'getpattern', 'getplanes', 'getport', 'getresetls', 'getscrmask', 0037 'getshade', 'getsize', 'getsm', 'gettp', 'getvaluator', 'getvideo', 0038 'getviewport', 'getwritemask', 'getzbuffer', 'gewrite', 'gflush', 0039 'ginit', 'glcompat', 'greset', 'gselect', 'gsync', 'gversion', 0040 'iconsize', 'icontitle', 'imakebackground', 'initnames', 'ismex', 0041 'isobj', 'isqueued', 'istag', 'keepaspect', 'lRGBrange', 'lampoff', 0042 'lampon', 'linesmooth', 'linewidth', 'lmbind', 'lmcolor', 'lmdef', 0043 'loadmatrix', 'loadname', 'logicop', 'lookat', 'lrectread', 0044 'lrectwrite', 'lsbackup', 'lsetdepth', 'lshaderange', 'lsrepeat', 0045 'makeobj', 'maketag', 'mapcolor', 'mapw', 'mapw2', 'maxsize', 0046 'minsize', 'mmode', 'move', 'move2', 'move2i', 'move2s', 'movei', 0047 'moves', 'multimap', 'multmatrix', 'n3f', 'newpup', 'newtag', 0048 'noborder', 'noise', 'noport', 'normal', 'nurbscurve', 'nurbssurface', 0049 'nvarray', 'objdelete', 'objinsert', 'objreplace', 'onemap', 'ortho', 0050 'ortho2', 'overlay', 'packrect', 'pagecolor', 'pagewritemask', 0051 'passthrough', 'patch', 'patchbasis', 'patchcurves', 'patchprecision', 0052 'pclos', 'pdr', 'pdr2', 'pdr2i', 'pdr2s', 'pdri', 'pdrs', 0053 'perspective', 'pick', 'picksize', 'pixmode', 'pmv', 'pmv2', 'pmv2i', 0054 'pmv2s', 'pmvi', 'pmvs', 'pnt', 'pnt2', 'pnt2i', 'pnt2s', 'pnti', 0055 'pnts', 'pntsmooth', 'polarview', 'polf', 'polf2', 'polf2i', 'polf2s', 0056 'polfi', 'polfs', 'poly', 'poly2', 'poly2i', 'poly2s', 'polyi', 0057 'polys', 'popattributes', 'popmatrix', 'popname', 'popviewport', 0058 'prefposition', 'prefsize', 'pupmode', 'pushattributes', 'pushmatrix', 0059 'pushname', 'pushviewport', 'pwlcurve', 'qdevice', 'qenter', 'qgetfd', 0060 'qread', 'qreset', 'qtest', 'rcrv', 'rcrvn', 'rdr', 'rdr2', 'rdr2i', 0061 'rdr2s', 'rdri', 'rdrs', 'readdisplay', 'readsource', 'rect', 0062 'rectcopy', 'rectf', 'rectfi', 'rectfs', 'recti', 'rects', 'rectzoom', 0063 'resetls', 'reshapeviewport', 'ringbell', 'rmv', 'rmv2', 'rmv2i', 0064 'rmv2s', 'rmvi', 'rmvs', 'rot', 'rotate', 'rpatch', 'rpdr', 'rpdr2', 0065 'rpdr2i', 'rpdr2s', 'rpdri', 'rpdrs', 'rpmv', 'rpmv2', 'rpmv2i', 0066 'rpmv2s', 'rpmvi', 'rpmvs', 'sbox', 'sboxf', 'sboxfi', 'sboxfs', 0067 'sboxi', 'sboxs', 'scale', 'screenspace', 'scrmask', 'setbell', 0068 'setcursor', 'setdepth', 'setlinestyle', 'setmap', 'setmonitor', 0069 'setnurbsproperty', 'setpattern', 'setpup', 'setshade', 'setvaluator', 0070 'setvideo', 'shademodel', 'shaderange', 'singlebuffer', 'smoothline', 0071 'spclos', 'splf', 'splf2', 'splf2i', 'splf2s', 'splfi', 'splfs', 0072 'stepunit', 'strwidth', 'subpixel', 'swapbuffers', 'swapinterval', 0073 'swaptmesh', 'swinopen', 'textcolor', 'textinit', 'textport', 0074 'textwritemask', 'tie', 'tpoff', 'tpon', 'translate', 'underlay', 0075 'unpackrect', 'unqdevice', 'v2d', 'v2f', 'v2i', 'v2s', 'v3d', 'v3f', 0076 'v3i', 'v3s', 'v4d', 'v4f', 'v4i', 'v4s', 'varray', 'videocmd', 0077 'viewport', 'vnarray', 'winattach', 'winclose', 'winconstraints', 0078 'windepth', 'window', 'winget', 'winmove', 'winopen', 'winpop', 0079 'winposition', 'winpush', 'winset', 'wintitle', 'wmpack', 'writemask', 0080 'writepixels', 'xfpt', 'xfpt2', 'xfpt2i', 'xfpt2s', 'xfpt4', 'xfpt4i', 0081 'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction', 0082 'zsource', 'zwritemask'] 0083 0084 def main(): 0085 # insure that we at least have an X display before continuing. 0086 import os 0087 try: 0088 display = os.environ['DISPLAY'] 0089 except: 0090 raise TestSkipped, "No $DISPLAY -- skipping gl test" 0091 0092 # touch all the attributes of gl without doing anything 0093 if verbose: 0094 print 'Touching gl module attributes...' 0095 for attr in glattrs: 0096 if verbose: 0097 print 'touching: ', attr 0098 getattr(gl, attr) 0099 0100 # create a small 'Crisscross' window 0101 if verbose: 0102 print 'Creating a small "CrissCross" window...' 0103 print 'foreground' 0104 gl.foreground() 0105 if verbose: 0106 print 'prefposition' 0107 gl.prefposition(500, 900, 500, 900) 0108 if verbose: 0109 print 'winopen "CrissCross"' 0110 w = gl.winopen('CrissCross') 0111 if verbose: 0112 print 'clear' 0113 gl.clear() 0114 if verbose: 0115 print 'ortho2' 0116 gl.ortho2(0.0, 400.0, 0.0, 400.0) 0117 if verbose: 0118 print 'color WHITE' 0119 gl.color(GL.WHITE) 0120 if verbose: 0121 print 'color RED' 0122 gl.color(GL.RED) 0123 if verbose: 0124 print 'bgnline' 0125 gl.bgnline() 0126 if verbose: 0127 print 'v2f' 0128 gl.v2f(0.0, 0.0) 0129 gl.v2f(400.0, 400.0) 0130 if verbose: 0131 print 'endline' 0132 gl.endline() 0133 if verbose: 0134 print 'bgnline' 0135 gl.bgnline() 0136 if verbose: 0137 print 'v2i' 0138 gl.v2i(400, 0) 0139 gl.v2i(0, 400) 0140 if verbose: 0141 print 'endline' 0142 gl.endline() 0143 if verbose: 0144 print 'Displaying window for 2 seconds...' 0145 time.sleep(2) 0146 if verbose: 0147 print 'winclose' 0148 gl.winclose(w) 0149 0150 main() 0151
Generated by PyXR 0.9.4