1
2
3
4
5
6
7
8
9
10 """
11 QuickTime movies in the Vision Egg.
12
13 """
14
15 import VisionEgg
16 import VisionEgg.gl_qt
17 import VisionEgg.qtmovie as qtmovie
18 import VisionEgg.Textures
19
20 import numpy.oldnumeric as Numeric
21 import os
22
23 import VisionEgg.GL as gl
24
25 __version__ = VisionEgg.release_name
26 __author__ = 'Andrew Straw <astraw@users.sourceforge.net>'
27
28
29
30 new_movie_from_filename = qtmovie.new_movie_from_filename
31
32 -class MovieTexture(VisionEgg.Textures.Texture):
33
34 __slots__ = (
35 'movie',
36 'size',
37 'scale',
38 'gl_qt_renderer',
39 )
40
41 - def __init__(self,
42 movie=None,
43 texture_size=None,
44 ):
45 if not isinstance(movie,qtmovie.Movie):
46 if isinstance(movie,str) or isinstance(movie,unicode):
47 movie = new_movie_from_filename(filename=movie)
48 self.movie = movie
49 bounds = self.movie.GetMovieBox()
50 height = bounds.bottom-bounds.top
51 width = bounds.right-bounds.left
52 self.movie.SetMovieBox(qtmovie.Rect(top=0,left=0,bottom=height,right=width))
53 self.size = (width,height)
54 self.scale = 1.0
55
56 - def make_half_size(self):
57 self.size = self.size[0]/2, self.size[1]/2
58 self.scale = self.scale/2
59
61 raise NotImplementedError('')
62
64 raise NotImplementedError('')
65
66 - def load(self, texture_object,
67 build_mipmaps=False,
68 rescale_original_to_fill_texture_object = False,
69 internal_format=gl.GL_RGB,
70 ):
71 if build_mipmaps:
72 raise ValueError('cannot build mipmaps for QuickTime movies')
73 if rescale_original_to_fill_texture_object:
74 raise NotImplementedError('')
75 width,height = self.size
76 tex_shape = VisionEgg.Textures.next_power_of_2(max(width,height))
77
78 self.buf_lf = 0.0
79 self.buf_rf = float(width)/tex_shape
80 self.buf_bf = 0.0
81 self.buf_tf = float(height)/tex_shape
82
83
84 self._buf_l = 0
85 self._buf_r = width
86 self._buf_b = 0
87 self._buf_t = height
88
89 buffer = Numeric.zeros( (tex_shape,tex_shape), Numeric.UInt8 )
90 texture_object.put_new_image( buffer,
91 internal_format=gl.GL_RGB,
92 mipmap_level=0 )
93 self.texture_object = texture_object
94
95 self.gl_qt_renderer = VisionEgg.gl_qt.gl_qt_renderer_create(self.movie,tex_shape,self.scale)
96
100
103