movie from offscreen windows

Hi,

I'm trying to display a movie with PTB-3 on Windows XP.
My trouble is that I
- need a lot of offscreen windows and have to hold all of them in memory
- and need large offscreen windows.

The reason for this is that I want to produce something like "rain"
from a Gaussian cloud. Basically, I have circles falling from the top
of the screen, starting with one, in a random location, and after a
temporal offset of some frames, the next drop starts to fall, again in
a random location. Because of the random locations, the offscreen
window has to span the width of the screen. My current program (file
attached) works, but it takes incredibly long for all the for-loops to
be completed (that is, once the OnscreenWindow is open, I have to wait
and wait and wait before the ellipses start to fall).

Is there any way I can make this more efficient (because I will need
many more than the 20 ellipses I let rain at the moment)? I tried to
be as close as possible to the structure of the movie demo given in
the toolbox, but maybe this is not the way to go here?

Thanks and greetings,
Anna

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Hi,

offscreen windows are seldomly needed anymore, only for
very complex stimuli. You probably can draw your circles
online with one of the fast batch drawing commands:

for i=1:nOfFrames
1. Compute location of your "raindrops" for next frame,
store them in a matrix/vector...

2. Screen('DrawDots') or Screen('FillOval'), passing the
matrix/vector with all circles at once.

3. Screen('Flip')
end

For simple filled, colored, smooth dots, look at DotDemo.m
Efficient drawing of lots of dots of different position, color
and size. Dot diameter is limited depending on your gfx-card,
somewhere between 10 pixels diameter (ancient hardware)
and 60 pixels diameter (recent hardware).

For filled ovals (non-circular, or bigger than the size limit of
'DrawDots'), you can use Screen('FillOval') but pass a whole
matrix of ovals instead of just a single oval.

See e.g., DrawingSpeedTest(800, 2, 1) to measure speed of
drawing of 800 filled ovals per frame, measured over 1000
frames.

-> A couple of hundred dots or ovals per frame should not
be a problem on recent hardware.

You need to use the latest 'beta' of PTB-3 for these features.

-mario

--- In psychtoolbox@yahoogroups.com, Anna.Seydell@... wrote:
>
> Hi,
>
> I'm trying to display a movie with PTB-3 on Windows XP.
> My trouble is that I
> - need a lot of offscreen windows and have to hold all of them in memory
> - and need large offscreen windows.
>
> The reason for this is that I want to produce something like "rain"
> from a Gaussian cloud. Basically, I have circles falling from the top
> of the screen, starting with one, in a random location, and after a
> temporal offset of some frames, the next drop starts to fall, again in
> a random location. Because of the random locations, the offscreen
> window has to span the width of the screen. My current program (file
> attached) works, but it takes incredibly long for all the for-loops to
> be completed (that is, once the OnscreenWindow is open, I have to wait
> and wait and wait before the ellipses start to fall).
>
> Is there any way I can make this more efficient (because I will need
> many more than the 20 ellipses I let rain at the moment)? I tried to
> be as close as possible to the structure of the movie demo given in
> the toolbox, but maybe this is not the way to go here?
>
> Thanks and greetings,
> Anna
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> % Works, is just WAY too slow. Part of the reason might be that I switch a
> % lot between offscreen windows, (well, no. In fact, I don't. I fill them
> % one after the other.) but what worries me is that even the
> % OpenWindow command takes 9 seconds to execute...
>
>
> clear all
> clear mex
> close all
> clc
>
> oldLevel = Screen('Preference', 'Verbosity', 2);
>
> screensize = get(0,'ScreenSize');
> screenwidth = screensize(3);
> screenheight = screensize(4);
>
> % INPUT
=======================================================
===========
> %%%%%%%%%%%%%%%%%%%%%%
> % ellipse parameters %
> %%%%%%%%%%%%%%%%%%%%%%
> color = [0 255 255]; % r g b, max = 255
> width = 20; % diameter of ellipse in x-direction (in px)
> height = 20;
>
> %%%%%%%%%%%%%%%%%%%%
> % cloud parameters %
> %%%%%%%%%%%%%%%%%%%%
> center_Gauss = screenwidth/2; % to be drawn randomly later, but constrain
> % it so that the majority of raindrops fall on the screen (that is, the
> % constraint should take into account center_Gauss and sd_Gauss
> sd_Gauss = 100; % pixel
> n_raindrops = 20;
> stepsize = 20; % defines how fast the ellipse will fall
> fall_prop = 2/3; % which proportion of the screen does the ellipse fall down?
> offset = 10; % How many frames after the previous ellipse does the next ellipse fall?
> %
=======================================================
==================
>
>
> source_rect_width = screenwidth;
> source_rect_height = screenheight * fall_prop;
>
> source_rect=[0 0 source_rect_width source_rect_height];
> display_rect = source_rect;
>
> center_x = center_Gauss + randn(1,n_raindrops) * sd_Gauss;
>
> nOfFrames = source_rect_height/stepsize + offset * length(center_x);
>
> window = Screen('OpenWindow', 0, [0 0 0]);
>
> % create movie frames in offscreen windows
> for i = 1:nOfFrames
> movieframe(i) = Screen('OpenOffscreenWindow', window, [0 0 0], source_rect);
> for ellipse = 1:length(center_x)
> if (center_x(ellipse) > width/2) & (center_x(ellipse) < (screenwidth - width/2))
> if (i > (ellipse-1)*offset) & (i <= source_rect_height/stepsize + offset*
(ellipse-1))
> Screen('FillOval', movieframe(i), color, [(center_x(ellipse)-width/2) (0
+stepsize*i-(ellipse-1)*stepsize*offset) (center_x(ellipse)+width/2) (height+stepsize*i-
(ellipse-1)*stepsize*offset)]);
> end;
> end;
> end;
> end;
> %
=======================================================
==================
>
> % show movie
> for i = 1:nOfFrames
> Screen('CopyWindow',movieframe(i),window,source_rect,display_rect);
> Screen('Flip', window);
> end;
>
> % clean up
> Screen('Preference', 'Verbosity', oldLevel);
> Screen('CloseAll');
> clear all
> clear mex
>