def main(): names = [] maxlen = 0 for name in dir(GL): if name[:3] == 'GD_': names.append(name) maxlen = max(maxlen, len(name)) for name in names: print name + (maxlen - len(name))*' ' + '=', print gl.getgdesc(getattr(GL, name))
def main(): names = [] maxlen = 0 for name in dir(GL): if name[:3] == 'GD_': names.append(name) maxlen = max(maxlen, len(name)) for name in names: print name + (maxlen - len(name)) * ' ' + '=', print gl.getgdesc(getattr(GL, name))
def is_entry_indigo(): # XXX hack, hack. We should call gl.gversion() but that doesn't # exist in earlier Python versions. Therefore we check the number # of bitplanes *and* the size of the monitor. xmax = gl.getgdesc(GL.GD_XPMAX) if xmax <> 1024: return 0 ymax = gl.getgdesc(GL.GD_YPMAX) if ymax != 768: return 0 r = gl.getgdesc(GL.GD_BITS_NORM_SNG_RED) g = gl.getgdesc(GL.GD_BITS_NORM_SNG_GREEN) b = gl.getgdesc(GL.GD_BITS_NORM_SNG_BLUE) return (r, g, b) == (3, 3, 2)
def _initcmap(self): map = [] if self.format in ('mono', 'grey4') and self.mustunpack: convcolor = conv_grey else: convcolor = choose_conversion(self.format) maxbits = gl.getgdesc(GL.GD_BITS_NORM_SNG_CMODE) if maxbits > 11: maxbits = 11 c0bits = self.c0bits c1bits = self.c1bits c2bits = self.c2bits if c0bits+c1bits+c2bits > maxbits: if self.fallback and c0bits < maxbits: # Cannot display frames in this mode, use grey self.skipchrom = 1 c1bits = c2bits = 0 convcolor = choose_conversion('grey') else: raise Error, 'Sorry, '+`maxbits`+ \ ' bits max on this machine' maxc0 = 1 << c0bits maxc1 = 1 << c1bits maxc2 = 1 << c2bits if self.offset == 0 and maxbits == 11: offset = 2048 else: offset = self.offset if maxbits <> 11: offset = offset & ((1<<maxbits)-1) self.color0 = None self.fixcolor0 = 0 for c0 in range(maxc0): c0v = c0/float(maxc0-1) for c1 in range(maxc1): if maxc1 == 1: c1v = 0 else: c1v = c1/float(maxc1-1) for c2 in range(maxc2): if maxc2 == 1: c2v = 0 else: c2v = c2/float(maxc2-1) index = offset + c0 + (c1<<c0bits) + \ (c2 << (c0bits+c1bits)) if index < MAXMAP: rv, gv, bv = \ convcolor(c0v, c1v, c2v) r, g, b = int(rv*255.0), \ int(gv*255.0), \ int(bv*255.0) map.append(index, r, g, b) if self.color0 == None: self.color0 = \ index, r, g, b self.install_colormap(map) # Permanently make the first color index current gl.color(self.color0[0])
def _initcmap(self): map = [] if self.format in ('mono', 'grey4') and self.mustunpack: convcolor = conv_grey else: convcolor = choose_conversion(self.format) maxbits = gl.getgdesc(GL.GD_BITS_NORM_SNG_CMODE) if maxbits > 11: maxbits = 11 c0bits = self.c0bits c1bits = self.c1bits c2bits = self.c2bits if c0bits + c1bits + c2bits > maxbits: if self.fallback and c0bits < maxbits: # Cannot display frames in this mode, use grey self.skipchrom = 1 c1bits = c2bits = 0 convcolor = choose_conversion('grey') else: raise Error, 'Sorry, '+`maxbits`+ \ ' bits max on this machine' maxc0 = 1 << c0bits maxc1 = 1 << c1bits maxc2 = 1 << c2bits if self.offset == 0 and maxbits == 11: offset = 2048 else: offset = self.offset if maxbits <> 11: offset = offset & ((1 << maxbits) - 1) self.color0 = None self.fixcolor0 = 0 for c0 in range(maxc0): c0v = c0 / float(maxc0 - 1) for c1 in range(maxc1): if maxc1 == 1: c1v = 0 else: c1v = c1 / float(maxc1 - 1) for c2 in range(maxc2): if maxc2 == 1: c2v = 0 else: c2v = c2 / float(maxc2 - 1) index = offset + c0 + (c1<<c0bits) + \ (c2 << (c0bits+c1bits)) if index < MAXMAP: rv, gv, bv = \ convcolor(c0v, c1v, c2v) r, g, b = int(rv*255.0), \ int(gv*255.0), \ int(bv*255.0) map.append((index, r, g, b)) if self.color0 == None: self.color0 = \ index, r, g, b self.install_colormap(map) # Permanently make the first color index current gl.color(self.color0[0])
#! /usr/bin/env python # Play CMIF movie files # Help function def help(): print 'Usage: Vplay [options] [file] ...' print print 'Options:' print '-M magnify : magnify the image by the given factor' print '-d : write some debug stuff on stderr' print '-l : loop, playing the movie over and over again' print '-m delta : drop frames closer than delta seconds (default 0.)' print '-n : don\'t wait after each file' print '-q : quiet, no informative messages' print '-r delta : regenerate input time base delta seconds apart' print '-s speed : speed change factor (default 1.0)' print '-t : use a 2nd thread for read-ahead' print '-x left : window offset from left of screen' print '-y top : window offset from top of screen' print '-w width : window width' print '-h height : window height' print '-b color : background color (white,black or (r,g,b))' print 'file ... : file(s) to play; default film.video' print print 'User interface:' print 'Press the left mouse button to stop or restart the movie.' print 'Press ESC or use the window manager Close or Quit command' print 'to close the window and play the next file (if any).' # Imported modules
if not quiet: vin.printinfo() gl.foreground() width, height = int(vin.width * magnify), int(vin.height * magnify) xborder = yborder = 0 if xwsiz: vin.xorigin = (xwsiz - width)/2 width = xwsiz if ywsiz: vin.yorigin = (ywsiz - height)/2 height = ywsiz if xoff <> None and yoff <> None: scrheight = gl.getgdesc(GL.GD_YPMAX) gl.prefposition(xoff, xoff+width-1, \ scrheight-yoff-height, scrheight-yoff-1) else: gl.prefsize(width, height) win = gl.winopen(filename) gl.clear() if quiet: vin.quiet = 1 vin.initcolormap() if bgcolor: r, g, b = bgcolor vin.clearto(r,g,b)
import sys
#! /usr/bin/env python
# Classes to read and write CMIF video files.