diff options
author | Guido van Rossum <guido@python.org> | 1991-10-30 11:52:48 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-10-30 11:52:48 (GMT) |
commit | e4bddeae233b107ee08f939e6645357fb245d8cb (patch) | |
tree | bb77370d73740914eecdeba9e1a31d7d9c7b0fae /Demo/sgi/video/tv.py | |
parent | baf0ebf43c45e85e9a47d25e5279c99ca9455838 (diff) | |
download | cpython-e4bddeae233b107ee08f939e6645357fb245d8cb.zip cpython-e4bddeae233b107ee08f939e6645357fb245d8cb.tar.gz cpython-e4bddeae233b107ee08f939e6645357fb245d8cb.tar.bz2 |
Initial revision
Diffstat (limited to 'Demo/sgi/video/tv.py')
-rwxr-xr-x | Demo/sgi/video/tv.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Demo/sgi/video/tv.py b/Demo/sgi/video/tv.py new file mode 100755 index 0000000..621740c --- /dev/null +++ b/Demo/sgi/video/tv.py @@ -0,0 +1,79 @@ +import string + +from socket import * +from gl import * +from GL import * +from DEVICE import * +from time import millisleep, millitimer + +PORT = 5555 + +PF = 2 # packfactor +HS = 40 # Header size + +def testimage(): + RGBcolor(0, 0, 0) + clear() + RGBcolor(0, 255, 0) + cmov2i(10, 10) + charstr('Waiting...') + +def reshape(): + reshapeviewport() + w, h = getsize() + ortho2(0, w, 0, h) + testimage() + return w, h + +def main(): + s = socket(AF_INET, SOCK_DGRAM) + s.bind('', PORT) + + foreground() + wid = winopen('tv') + RGBmode() + gconfig() + qdevice(ESCKEY) + + oldw, oldh = getsize() + ortho2(0, oldw, 0, oldh) + testimage() + + t1 = millitimer() + + while 1: + if qtest(): + dev, val = qread() + if dev = ESCKEY: + winclose(wid) + return + elif dev = REDRAW: + oldw, oldh = reshape() + elif s.avail(): + data = s.recv(17000) + header = string.strip(data[:HS]) + w, h, pf, x1, y1, x2, y2 = eval(header) + if (w, h) <> (oldw, oldh): + x, y = getorigin() + x, y = x-1, y+21 # TWM correction + winposition(x, x+w-1, y+oldh-h, y+oldh-1) + oldw, oldh = reshape() + data2 = data[HS:] + dx = (x2-x1+1)/pf + dy = (y2-y1+1)/pf + data3 = unpackrect(dx, dy, 1, data2) + rectzoom(pf, pf) + lrectwrite(x1, y1, x1+dx-1, y1+dy-1, data3) + t1 = millitimer() + else: + t2 = millitimer() + if t2-t1 >= 5000: + testimage() + t1 = t2 + else: + millisleep(10) + + winclose(wid) + return data + +main() |