Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 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 | """ |
Barry Warsaw | 408b6d3 | 2002-07-30 23:27:12 +0000 | [diff] [blame] | 6 | from test.test_support import verbose, TestSkipped |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 7 | import gl, GL, time |
| 8 | |
| 9 | glattrs = ['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 | |
| 84 | def main(): |
| 85 | # insure that we at least have an X display before continuing. |
| 86 | import os |
| 87 | try: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 88 | display = os.environ['DISPLAY'] |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 89 | except: |
Thomas Wouters | b9fa0a8 | 2000-08-04 13:34:43 +0000 | [diff] [blame] | 90 | raise TestSkipped, "No $DISPLAY -- skipping gl test" |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 91 | |
| 92 | # touch all the attributes of gl without doing anything |
| 93 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 94 | print('Touching gl module attributes...') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 95 | for attr in glattrs: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 96 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 97 | print('touching: ', attr) |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 98 | getattr(gl, attr) |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 99 | |
| 100 | # create a small 'Crisscross' window |
| 101 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 102 | print('Creating a small "CrissCross" window...') |
| 103 | print('foreground') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 104 | gl.foreground() |
| 105 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 106 | print('prefposition') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 107 | gl.prefposition(500, 900, 500, 900) |
| 108 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 109 | print('winopen "CrissCross"') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 110 | w = gl.winopen('CrissCross') |
| 111 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 112 | print('clear') |
Guido van Rossum | 9d1a02c | 1997-01-03 22:42:08 +0000 | [diff] [blame] | 113 | gl.clear() |
| 114 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 115 | print('ortho2') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 116 | gl.ortho2(0.0, 400.0, 0.0, 400.0) |
| 117 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 118 | print('color WHITE') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 119 | gl.color(GL.WHITE) |
| 120 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 121 | print('color RED') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 122 | gl.color(GL.RED) |
| 123 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 124 | print('bgnline') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 125 | gl.bgnline() |
| 126 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 127 | print('v2f') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 128 | gl.v2f(0.0, 0.0) |
| 129 | gl.v2f(400.0, 400.0) |
| 130 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 131 | print('endline') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 132 | gl.endline() |
| 133 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 134 | print('bgnline') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 135 | gl.bgnline() |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 136 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 137 | print('v2i') |
Guido van Rossum | 9d1a02c | 1997-01-03 22:42:08 +0000 | [diff] [blame] | 138 | gl.v2i(400, 0) |
| 139 | gl.v2i(0, 400) |
| 140 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 141 | print('endline') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 142 | gl.endline() |
Guido van Rossum | 9d1a02c | 1997-01-03 22:42:08 +0000 | [diff] [blame] | 143 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 144 | print('Displaying window for 2 seconds...') |
Guido van Rossum | 9d1a02c | 1997-01-03 22:42:08 +0000 | [diff] [blame] | 145 | time.sleep(2) |
| 146 | if verbose: |
Guido van Rossum | be19ed7 | 2007-02-09 05:37:30 +0000 | [diff] [blame] | 147 | print('winclose') |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 148 | gl.winclose(w) |
Fred Drake | 004d5e6 | 2000-10-23 17:22:08 +0000 | [diff] [blame] | 149 | |
Roger E. Masse | 6da2953 | 1996-12-24 19:36:07 +0000 | [diff] [blame] | 150 | main() |