1996-12-24 15:36:07 -04:00
|
|
|
"""Very simple test script for the SGI gl library extension module
|
|
|
|
taken mostly from the documentation.
|
|
|
|
Roger E. Masse
|
|
|
|
"""
|
2010-02-06 19:06:24 -04:00
|
|
|
import unittest
|
2009-03-30 16:04:00 -03:00
|
|
|
from test.test_support import verbose, import_module
|
|
|
|
import time
|
|
|
|
gl = import_module('gl')
|
|
|
|
GL = import_module('GL')
|
1996-12-24 15:36:07 -04:00
|
|
|
|
|
|
|
glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
|
|
|
|
'__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf',
|
|
|
|
'arcfi', 'arcfs', 'arci', 'arcs', 'attachcursor', 'backbuffer',
|
|
|
|
'backface', 'bbox2', 'bbox2i', 'bbox2s', 'bgnclosedline', 'bgnline',
|
|
|
|
'bgnpoint', 'bgnpolygon', 'bgnsurface', 'bgntmesh', 'bgntrim',
|
|
|
|
'blankscreen', 'blanktime', 'blendfunction', 'blink', 'c3f', 'c3i',
|
|
|
|
'c3s', 'c4f', 'c4i', 'c4s', 'callobj', 'charstr', 'chunksize', 'circ',
|
|
|
|
'circf', 'circfi', 'circfs', 'circi', 'circs', 'clear',
|
|
|
|
'clearhitcode', 'clkoff', 'clkon', 'closeobj', 'cmode', 'cmov',
|
|
|
|
'cmov2', 'cmov2i', 'cmov2s', 'cmovi', 'cmovs', 'color', 'colorf',
|
|
|
|
'compactify', 'concave', 'cpack', 'crv', 'crvn', 'curorigin',
|
|
|
|
'cursoff', 'curson', 'curstype', 'curvebasis', 'curveit',
|
|
|
|
'curveprecision', 'cyclemap', 'czclear', 'defbasis', 'defcursor',
|
|
|
|
'deflinestyle', 'delobj', 'deltag', 'depthcue', 'devport', 'dglclose',
|
|
|
|
'dglopen', 'dither', 'dopup', 'doublebuffer', 'draw', 'draw2',
|
|
|
|
'draw2i', 'draw2s', 'drawi', 'drawmode', 'draws', 'editobj',
|
|
|
|
'endclosedline', 'endfullscrn', 'endline', 'endpick', 'endpoint',
|
|
|
|
'endpolygon', 'endpupmode', 'endselect', 'endsurface', 'endtmesh',
|
|
|
|
'endtrim', 'finish', 'font', 'foreground', 'freepup', 'frontbuffer',
|
|
|
|
'fudge', 'fullscrn', 'gRGBcolor', 'gRGBmask', 'gammaramp', 'gbegin',
|
|
|
|
'gconfig', 'genobj', 'gentag', 'getbackface', 'getbuffer',
|
|
|
|
'getbutton', 'getcmmode', 'getcolor', 'getcpos', 'getcursor',
|
|
|
|
'getdcm', 'getdepth', 'getdescender', 'getdisplaymode', 'getdrawmode',
|
|
|
|
'getfont', 'getgdesc', 'getgpos', 'getheight', 'gethitcode',
|
|
|
|
'getlsbackup', 'getlsrepeat', 'getlstyle', 'getlwidth', 'getmap',
|
|
|
|
'getmatrix', 'getmcolor', 'getmmode', 'getmonitor',
|
|
|
|
'getnurbsproperty', 'getopenobj', 'getorigin', 'getothermonitor',
|
|
|
|
'getpattern', 'getplanes', 'getport', 'getresetls', 'getscrmask',
|
|
|
|
'getshade', 'getsize', 'getsm', 'gettp', 'getvaluator', 'getvideo',
|
|
|
|
'getviewport', 'getwritemask', 'getzbuffer', 'gewrite', 'gflush',
|
|
|
|
'ginit', 'glcompat', 'greset', 'gselect', 'gsync', 'gversion',
|
|
|
|
'iconsize', 'icontitle', 'imakebackground', 'initnames', 'ismex',
|
|
|
|
'isobj', 'isqueued', 'istag', 'keepaspect', 'lRGBrange', 'lampoff',
|
|
|
|
'lampon', 'linesmooth', 'linewidth', 'lmbind', 'lmcolor', 'lmdef',
|
|
|
|
'loadmatrix', 'loadname', 'logicop', 'lookat', 'lrectread',
|
|
|
|
'lrectwrite', 'lsbackup', 'lsetdepth', 'lshaderange', 'lsrepeat',
|
|
|
|
'makeobj', 'maketag', 'mapcolor', 'mapw', 'mapw2', 'maxsize',
|
|
|
|
'minsize', 'mmode', 'move', 'move2', 'move2i', 'move2s', 'movei',
|
|
|
|
'moves', 'multimap', 'multmatrix', 'n3f', 'newpup', 'newtag',
|
|
|
|
'noborder', 'noise', 'noport', 'normal', 'nurbscurve', 'nurbssurface',
|
|
|
|
'nvarray', 'objdelete', 'objinsert', 'objreplace', 'onemap', 'ortho',
|
|
|
|
'ortho2', 'overlay', 'packrect', 'pagecolor', 'pagewritemask',
|
|
|
|
'passthrough', 'patch', 'patchbasis', 'patchcurves', 'patchprecision',
|
|
|
|
'pclos', 'pdr', 'pdr2', 'pdr2i', 'pdr2s', 'pdri', 'pdrs',
|
|
|
|
'perspective', 'pick', 'picksize', 'pixmode', 'pmv', 'pmv2', 'pmv2i',
|
|
|
|
'pmv2s', 'pmvi', 'pmvs', 'pnt', 'pnt2', 'pnt2i', 'pnt2s', 'pnti',
|
|
|
|
'pnts', 'pntsmooth', 'polarview', 'polf', 'polf2', 'polf2i', 'polf2s',
|
|
|
|
'polfi', 'polfs', 'poly', 'poly2', 'poly2i', 'poly2s', 'polyi',
|
|
|
|
'polys', 'popattributes', 'popmatrix', 'popname', 'popviewport',
|
|
|
|
'prefposition', 'prefsize', 'pupmode', 'pushattributes', 'pushmatrix',
|
|
|
|
'pushname', 'pushviewport', 'pwlcurve', 'qdevice', 'qenter', 'qgetfd',
|
|
|
|
'qread', 'qreset', 'qtest', 'rcrv', 'rcrvn', 'rdr', 'rdr2', 'rdr2i',
|
|
|
|
'rdr2s', 'rdri', 'rdrs', 'readdisplay', 'readsource', 'rect',
|
|
|
|
'rectcopy', 'rectf', 'rectfi', 'rectfs', 'recti', 'rects', 'rectzoom',
|
|
|
|
'resetls', 'reshapeviewport', 'ringbell', 'rmv', 'rmv2', 'rmv2i',
|
|
|
|
'rmv2s', 'rmvi', 'rmvs', 'rot', 'rotate', 'rpatch', 'rpdr', 'rpdr2',
|
|
|
|
'rpdr2i', 'rpdr2s', 'rpdri', 'rpdrs', 'rpmv', 'rpmv2', 'rpmv2i',
|
|
|
|
'rpmv2s', 'rpmvi', 'rpmvs', 'sbox', 'sboxf', 'sboxfi', 'sboxfs',
|
|
|
|
'sboxi', 'sboxs', 'scale', 'screenspace', 'scrmask', 'setbell',
|
|
|
|
'setcursor', 'setdepth', 'setlinestyle', 'setmap', 'setmonitor',
|
|
|
|
'setnurbsproperty', 'setpattern', 'setpup', 'setshade', 'setvaluator',
|
|
|
|
'setvideo', 'shademodel', 'shaderange', 'singlebuffer', 'smoothline',
|
|
|
|
'spclos', 'splf', 'splf2', 'splf2i', 'splf2s', 'splfi', 'splfs',
|
|
|
|
'stepunit', 'strwidth', 'subpixel', 'swapbuffers', 'swapinterval',
|
|
|
|
'swaptmesh', 'swinopen', 'textcolor', 'textinit', 'textport',
|
|
|
|
'textwritemask', 'tie', 'tpoff', 'tpon', 'translate', 'underlay',
|
|
|
|
'unpackrect', 'unqdevice', 'v2d', 'v2f', 'v2i', 'v2s', 'v3d', 'v3f',
|
|
|
|
'v3i', 'v3s', 'v4d', 'v4f', 'v4i', 'v4s', 'varray', 'videocmd',
|
|
|
|
'viewport', 'vnarray', 'winattach', 'winclose', 'winconstraints',
|
|
|
|
'windepth', 'window', 'winget', 'winmove', 'winopen', 'winpop',
|
|
|
|
'winposition', 'winpush', 'winset', 'wintitle', 'wmpack', 'writemask',
|
|
|
|
'writepixels', 'xfpt', 'xfpt2', 'xfpt2i', 'xfpt2s', 'xfpt4', 'xfpt4i',
|
|
|
|
'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction',
|
|
|
|
'zsource', 'zwritemask']
|
|
|
|
|
2008-03-03 00:19:29 -04:00
|
|
|
def test_main():
|
1996-12-24 15:36:07 -04:00
|
|
|
# insure that we at least have an X display before continuing.
|
|
|
|
import os
|
|
|
|
try:
|
1998-03-26 15:42:58 -04:00
|
|
|
display = os.environ['DISPLAY']
|
1996-12-24 15:36:07 -04:00
|
|
|
except:
|
2009-03-26 18:10:30 -03:00
|
|
|
raise unittest.SkipTest, "No $DISPLAY -- skipping gl test"
|
1996-12-24 15:36:07 -04:00
|
|
|
|
|
|
|
# touch all the attributes of gl without doing anything
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'Touching gl module attributes...'
|
1996-12-24 15:36:07 -04:00
|
|
|
for attr in glattrs:
|
1998-03-26 15:42:58 -04:00
|
|
|
if verbose:
|
|
|
|
print 'touching: ', attr
|
|
|
|
getattr(gl, attr)
|
1996-12-24 15:36:07 -04:00
|
|
|
|
|
|
|
# create a small 'Crisscross' window
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'Creating a small "CrissCross" window...'
|
|
|
|
print 'foreground'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.foreground()
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'prefposition'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.prefposition(500, 900, 500, 900)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'winopen "CrissCross"'
|
1996-12-24 15:36:07 -04:00
|
|
|
w = gl.winopen('CrissCross')
|
1997-01-03 18:42:08 -04:00
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'clear'
|
1997-01-03 18:42:08 -04:00
|
|
|
gl.clear()
|
1996-12-24 15:36:07 -04:00
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'ortho2'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.ortho2(0.0, 400.0, 0.0, 400.0)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'color WHITE'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.color(GL.WHITE)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'color RED'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.color(GL.RED)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'bgnline'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.bgnline()
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'v2f'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.v2f(0.0, 0.0)
|
|
|
|
gl.v2f(400.0, 400.0)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'endline'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.endline()
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'bgnline'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.bgnline()
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'v2i'
|
1997-01-03 18:42:08 -04:00
|
|
|
gl.v2i(400, 0)
|
|
|
|
gl.v2i(0, 400)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'endline'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.endline()
|
1997-01-03 18:42:08 -04:00
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'Displaying window for 2 seconds...'
|
1997-01-03 18:42:08 -04:00
|
|
|
time.sleep(2)
|
|
|
|
if verbose:
|
1998-03-26 15:42:58 -04:00
|
|
|
print 'winclose'
|
1996-12-24 15:36:07 -04:00
|
|
|
gl.winclose(w)
|
2000-10-23 14:22:08 -03:00
|
|
|
|
2008-03-03 00:19:29 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|