On Fri, 5 Aug 2005, David Fencsik wrote:
> Maria,
>
> In your sample code, the ovals are drawn to off-screen windows that
> are the same size as the on-screen window. This means that you are
> copying a whole lot of unnecessary bytes every time a stimulus is
> copied to the screen. Try making the off-screen stimulus windows as
> small as possible (i.e., the max radius of the ovals).
>
> David
>
Hi David,
Thanks for the advice. The reason I did that is because I was having problems with the rectangles showing up when stimuli overlapped, if I didn't. Using the large off-screen window did not cause a timing problem in the black and white version, so I thought it should work with the color too. I really don't understand why it wouldn't, but if you have another idea of how to do this without the rectangles showing up, that would be great. I'm including some code that demonstrates what I mean about the rectangles.
Tyi, this code will eventually be incorporated in a gui, in which the user is able to make the two circles any size, and put them anywhere on the screen (including one on top of the other, as in this demo). Sometimes they will both be shown at the same time, and sometimes just one at a time.
thanks,
Maria
% MailListDemo2
% adapted from Psychtoolbox MovieDemo2
% show on main screen
whichScreen=0;
nFrames=round(0.5*FrameRate(whichScreen));
priorityLevel=MaxPriority(whichScreen,'GetSecs','WaitBlanking');
% Open screen. Do this before opening the
% offscreen windows so you can align offscreen
% window memory to onscreen for faster copying.
[window,windowRect]=Screen(whichScreen,'OpenWindow',0,[],8);
onClut=(0:255)'*[1 1 1];
Screen(window,'SetClut',onClut);
imageRect=SetRect(0,0,200,200);
imageRect2=SetRect(0,0,300,300);
destRect=CenterRect(imageRect,windowRect);
destRect2=CenterRect(imageRect2,windowRect);
% Put images into offscreen memory. When we open an offscreen
% window we specify which on-screen window it should be
% aligned with, for fast copying.
ow1=Screen(window,'OpenOffscreenWindow',0,imageRect,8);
Screen(ow1,'FillOval', 100, imageRect);
ow2=Screen(window,'OpenOffscreenWindow',0,imageRect2,8);
Screen(ow2,'FillOval', 255, imageRect2);
% Set up string for Rush. You can make this as long as you like.
% The initial call to WaitBlanking synchronizes the program with the display blanking.
missed1=zeros(nFrames,1);
missed2=zeros(nFrames,1);
GetSecs;
% Preload all functions.
loop={
'Screen(window,''WaitBlanking'');'
'startTime=GetSecs;'
'for i=1:nFrames;'
'Screen(''CopyWindow'', ow1, window,imageRect,destRect,''srcCopy'');'
'missed1(i)=Screen(window,''WaitBlanking'');'
'Screen(''CopyWindow'', ow2, window,imageRect2,destRect2,''srcCopy'');'
'missed2(i)=Screen(window,''WaitBlanking'');'
'end;'
'finishTime=GetSecs;'
};
% Show the movie. The Rushed code does the timing.
HideCursor;
Screen('Screens');GetSecs; % Make sure all Rushed functions are in memory.
Rush(loop,priorityLevel);
ShowCursor;
% Close up
Screen('CloseAll');
% Print results
fprintf('MovieDemo3\n');
s=sprintf('Movie is %.0f Hz.',FrameRate(whichScreen));
s=sprintf('%s Copied %.0f images/sec.',s,2*nFrames/(finishTime-startTime));
s=sprintf('%s Missed %g frames.',s,sum(sum([missed1 missed2])));
fprintf('%s\n',WrapString(s));
RestoreScreen(whichScreen);
% As of 7/31/02, FrameRate may leave CLUT in strange state.