image-making for movies

Using Matlab 7 and PTB 3.

I would like to create and play a movie. The easiest way I see to do
this is to use Screen('MakeTexture' ...) to generate each frame.
However, MakeTexture seems to presuppose some sort of image map, and I
would like to use the drawing commands ('DrawLine', 'FillOval', etc.)
to draw each frame.

According to the FAQ, textures and offscreen windows are more or less
the same, except that you can draw to offscreen windows, but not to
textures. It states that 'MakeTexture' is faster than 'PutImage'.
(which I already know from the tutorial) However, it goes on to state
that "The advantage is also that the Screen('DrawTexture') command
allows [one] to scale, zoom, filter and rotate textures while drawing,
that texture drawing is extremely fast as it uses specialized hardware
on your graphics card, and much more..." This suggests that there is
a fundamental difference between using textures and offscreen windows,
but I don't know what that is.

I've tried using offscreen windows for each frame, but for 300 frames,
it slows down a lot after about frame 30. I assume this is some sort
of memory issue.

I guess in the end, what I want to know is, how do I draw to an image
map so that I can make textures optimized for movie playback. I guess
an alternate solution would be to copy an offscreen window into a
texture without the "slow" 'GetImage' command, so that I don't have to
have a bunch of offscreen windows floating around.

I especially like how MovieDemo.m states "We don't need offscreen
windows as in OS 9. FillOval is now fast enough to draw ovals during
the animation." Umm, what happens when we have enough drawing that
the animation can't keep up? What if we want to draw the frames
beforehand anyway? What an utterly useless demo.
Twenty objects should not be a problem - depending on the objects. Matlab runs your
code much faster if it is declared as a function instead of a script. For lines and dots, see
the 'DrawLines' and 'DrawDots' functions (DotDemo and LinesDemo) - thousands of dots
or lines are not a problem. I'd give on-the-fly drawing a try if i were you.

Apart from that, offscreen windows and textures are the same, as stated in the FAQ that
you mentioned. You can open an offscreen window, draw into it, later use it as if it is a
texture, e.g., via 'DrawTexture'. Do you provide the 'rect' parameter to the
'OpenOffscreenWindow' call to restrict its size to the size of your stimulus? If you don't,
then each offscreenwindow will be screen-sized, using up lots of memory. Also don't
forget to close offscreen windows that you don't need anymore.

Finally, if you have a recent gfx-card (Radeon 9600 or GeForceFX5200 and later), you can
use a much faster implementation of offscreen windows by setting the optional
imagingMode flag of Screen('OpenWindow, ...., imagingMode) to the value
kPsychNeedFastBackingStore.

what kind of stimuli do you draw?


--- In psychtoolbox@yahoogroups.com, "ye_hao" <ye_hao@...> wrote:
>
> About twenty objects, but I'm wary of the Matlab overhead for
> interpreting each line. If there were a way to draw a bunch of
> objects with one line of code, maybe I wouldn't worry so much about speed.
>
> Either way, it seems that using PutImage to convert an offscreen
> window into a imagemap to use in MakeTexture works ok, but I'm not
> convinced that that is the ideal method to use.
>
> --- In psychtoolbox@yahoogroups.com, Keith Schneider <ks@> wrote:
> >
> > Dear Ye_hao,
> >
> > How many objects (lines, ovals, etc.) do you want to draw each
> > frame? The drawing commands are very fast now, as you noted in the
> > demo, and you would have to draw quite a few of them to overwhelm
> > recent graphics cards on each frame.
> >
> > keith
> >
> >
>
--- In psychtoolbox@yahoogroups.com, "Mario Kleiner"
<mario.kleiner@...> wrote:
>
> Twenty objects should not be a problem - depending on the objects.
Matlab runs your
> code much faster if it is declared as a function instead of a
script. For lines and dots, see
> the 'DrawLines' and 'DrawDots' functions (DotDemo and LinesDemo) -
thousands of dots
> or lines are not a problem. I'd give on-the-fly drawing a try if i
were you.
>
> Apart from that, offscreen windows and textures are the same, as
stated in the FAQ that
> you mentioned. You can open an offscreen window, draw into it, later
use it as if it is a
> texture, e.g., via 'DrawTexture'. Do you provide the 'rect'
parameter to the
> 'OpenOffscreenWindow' call to restrict its size to the size of your
stimulus? If you don't,
> then each offscreenwindow will be screen-sized, using up lots of
memory. Also don't
> forget to close offscreen windows that you don't need anymore.
>
> Finally, if you have a recent gfx-card (Radeon 9600 or GeForceFX5200
and later), you can
> use a much faster implementation of offscreen windows by setting the
optional
> imagingMode flag of Screen('OpenWindow, ...., imagingMode) to the value
> kPsychNeedFastBackingStore.
>
> what kind of stimuli do you draw?

I'm drawing a bunch of circles as part of a biomotion stimulus.

Thanks for the tips, but it seems like both 'DrawDots' and 'DrawLines'
are OS X only functions, at least according to the listing when I run
Screen by itself.

Where do I find documentation about the imagingMode parameter?
'OpenWindow' tells me to "Read 'help PsychImagingMode' for information
about this feature.", but that doesn't seem to work.