示例#1
0
	def reshapewindow(self):
		oldwid = gl.winget()
		gl.winset(self.wid)
		gl.reshapeviewport()
		w, h = gl.getsize()
		self.disp.xorigin = (w-self.vw)/2
		self.disp.yorigin = (h-self.vh)/2
		self.disp.clear()
		gl.winset(oldwid)
示例#2
0
 def _fixviewport(self):
     #
     # Called after redraw or resize, and initially.
     #
     # Fix the coordinate system so that (0, 0) is top left,
     # units are pixels, and positive axes point right and down.
     #
     # Make the viewport slightly larger than the window,
     # and set the screenmask exactly to the window; this
     # help fixing character clipping.
     #
     # Set self._area to the window rectangle in STDWIN coords.
     #
     gl.winset(self._gid)
     gl.reshapeviewport()
     x0, x1, y0, y1 = gl.getviewport()
     width, height = x1 - x0, y1 - y0
     gl.viewport(x0 - MASK, x1 + MASK, y0 - MASK, y1 + MASK)
     gl.scrmask(x0, x1, y0, y1)
     gl.ortho2(-MASK, width + MASK, height + MASK, -MASK)
     self._area = (0, 0), (width, height)
示例#3
0
	def _fixviewport(self):
		#
		# Called after redraw or resize, and initially.
		#
		# Fix the coordinate system so that (0, 0) is top left,
		# units are pixels, and positive axes point right and down.
		#
		# Make the viewport slightly larger than the window,
		# and set the screenmask exactly to the window; this
		# help fixing character clipping.
		#
		# Set self._area to the window rectangle in STDWIN coords.
		#
		gl.winset(self._gid)
		gl.reshapeviewport()
		x0, x1, y0, y1 = gl.getviewport()
		width, height = x1-x0, y1-y0
		gl.viewport(x0-MASK, x1+MASK, y0-MASK, y1+MASK)
		gl.scrmask(x0, x1, y0, y1)
		gl.ortho2(-MASK, width+MASK, height+MASK, -MASK)
		self._area = (0, 0), (width, height)
示例#4
0
import gl, GL
示例#5
0
import gl, GL
示例#6
0
文件: Vplay.py 项目: mcyril/ravel-ftn
#! /usr/bin/env python
示例#7
0
def playonce(vin):
	vin.rewind()
	vin.colormapinited = 1
	vin.magnify = magnify

	if threading:
		MAXSIZE = 20 # Don't read ahead too much
		import thread
		import Queue
		queue = Queue.Queue(MAXSIZE)
		stop = []
		thread.start_new_thread(read_ahead, (vin, queue, stop))
		# Get the read-ahead thread going
		while queue.qsize() < MAXSIZE/2 and not stop:
			time.sleep(0.100)

	tin = 0
	toffset = 0
	oldtin = 0
	told = 0
	nin = 0
	nout = 0
	nlate = 0
	nskipped = 0
	data = None

	tlast = t0 = time.time()

	while 1:
		if gl.qtest():
			dev, val = gl.qread()
			if dev == ESCKEY and val == 1 or \
					dev in (WINSHUT, WINQUIT) or \
					dev == LEFTMOUSE and val == 1:
				if debug: sys.stderr.write('\n')
				if threading:
					stop.append(None)
					while 1:
						item = queue.get()
						if item == None: break
				return (dev != LEFTMOUSE)
			if dev == REDRAW:
				gl.reshapeviewport()
				if data: vin.showframe(data, cdata)
		if threading:
			if debug and queue.empty(): sys.stderr.write('.')
			item = queue.get()
			if item == None: break
			tin, data, cdata = item
		else:
			try:
				tin, size, csize = vin.getnextframeheader()
			except EOFError:
				break
		tin = tin*0.001
		nin = nin+1
		if tin+toffset < oldtin:
			print 'Fix reversed time:', oldtin, 'to', tin
			toffset = oldtin - tin
		tin = tin + toffset
		oldtin = tin
		if regen: tout = nin * regen
		else: tout = tin
		tout = tout / speed
		if tout - told < mindelta:
			nskipped = nskipped + 1
			if not threading:
				vin.skipnextframedata(size, csize)
		else:
			if not threading:
				try:
					data, cdata = \
					  vin.getnextframedata(size, csize)
				except EOFError:
					if not quiet:
						print '[incomplete last frame]'
					break
			now = time.time()
			dt = (tout-told) - (now-tlast)
			told = tout
			if debug: sys.stderr.write(`round(dt, 3)` + ' ')
			if dt < 0: nlate = nlate + 1
			if dt > 0:
				time.sleep(dt)
				now = time.time()
			tlast = now
			vin.showframe(data, cdata)
			nout = nout + 1

	t1 = time.time()

	if debug: sys.stderr.write('\n')

	if quiet: return 0

	print 'Recorded:', nin, 'frames in', round(tin, 3), 'sec.',
	if tin: print '-- average', round(nin/tin, 1), 'frames/sec',
	print

	if nskipped: print 'Skipped', nskipped, 'frames'

	tout = t1-t0
	print 'Played:', nout,
	print 'frames in', round(tout, 3), 'sec.',
	if tout: print '-- average', round(nout/tout, 1), 'frames/sec',
	print

	if nlate: print 'There were', nlate, 'late frames'

	return 0
示例#8
0
import sys
示例#9
0
文件: Vplay.py 项目: mcyril/ravel-ftn
#! /usr/bin/env python
示例#10
0
	def redraw(self, wid):
		if wid == self.wid >= 0:
			gl.winset(self.wid)
			gl.reshapeviewport()
			self.vin.clear()
			self.show()
示例#11
0
import sys
示例#12
0
# Live video output (display video on the screen, presumably from the net)
示例#13
0
# Live video output (display video on the screen, presumably from the net)
示例#14
0
 def redraw(self, wid):
     if wid == self.wid >= 0:
         gl.winset(self.wid)
         gl.reshapeviewport()
         self.vin.clear()
         self.show()