'Flip' - "don't clear" parameter

Dear Forum,

I am using the latest release of the Psychtoolbox for Mac OS X.

For the purpose of my experiment, it is important to have a white rectangle in the lower
left corner during the presentation of the actual stimuli.
The actual stimuli are 'flipped' a lot, and while the rectangle mustn't be affected by those
'Flip' commands, I 'flip' the rectangle as follows:

Screen('Flip', w, [], 1); % where the last 'don't clear' parameter is set to '1'.

to prevent it from being cleared.

But: of course the next normal 'Flip' clears it and this is exactly what it should do to all the
other graphical elements, but not to the rectangle.
Is there any way to spare the rectangle permanently from getting 'flipped' away?

So basically I am looking for a way to make the white rectangle part of the background
(just as the initial

black=BlackIndex(0);
Screen('FillRect',w, black);
Screen('Flip', w);

causes the blackground to be black)
though it should be possible to switch off / hide the white rectangle from time to time.

I would be glad to hear any suggestion!

Thanks,

-Fabian Stelzer
Dear Fabian,

what you want (only clearing parts of the screen) is not possible and
won't be in the future unless somebody can provide a very convincing
reason for the need of such a function.

But the obvious solution is to simply redraw your white rectangle after
invocation of Screen('Flip')... -- What's wrong with that simple solution?

Just for the record: There are three clearmodes...

dontclear=2 -- The content of the backbuffer after Screen('Flip') is
identical to the previous content of the frontbuffer -- the image that
was on display *before* the Flip command is now available for overdrawing.
This mode is the fastest - it takes 0.0 Milliseconds.

dontclear=0 -- This is the default mode: The backbuffer is cleared to
background color. Takes a bit of time, depending on display resolution
and performance of your gfx-card maybe between 0.1 ms and 2 ms.

dontclear=1 -- Keep content after Flip - This is the slowest method,
because its implemented via making a backup copy of the buffer before
Flip and then restore buffer from backup after flip. Can take from 1 ms
up to multiple milliseconds. This mode is mostly meant for stimuli that
are so complex to draw that redrawing them from scratch would cost
much more time than the multiple milliseconds that dontclear=1 itself
needs.

dontclear=2 can be interesting if one overdraws a specific area of the
screen after each Flip anyway, e.g., if you present a centered image
that changes at each redraw. Then you could do:

Screen('FillRect', win, 0); % Clear buffer with black.
Screen('Flip', win); % Show blank screen.
Screen('Flip', win); % Show blank screen, clear 2nd buffer.

for i=1:trials
% Overdraw stuff from last trial with new stuff from...
% new trial. Needs special caution when using Alpha-
% blending...
...
% Flip buffers. Don't clear or restore anything...
Screen('Flip', win, [], 2);
end;

best,
-mario

--- In psychtoolbox@yahoogroups.com, "fabian_stelzer" <fabian_stelzer@y...> wrote:
>
> Dear Forum,
>
> I am using the latest release of the Psychtoolbox for Mac OS X.
>
> For the purpose of my experiment, it is important to have a white rectangle in the lower
> left corner during the presentation of the actual stimuli.
> The actual stimuli are 'flipped' a lot, and while the rectangle mustn't be affected by
those
> 'Flip' commands, I 'flip' the rectangle as follows:
>
> Screen('Flip', w, [], 1); % where the last 'don't clear' parameter is set to '1'.
>
> to prevent it from being cleared.
>
> But: of course the next normal 'Flip' clears it and this is exactly what it should do to all
the
> other graphical elements, but not to the rectangle.
> Is there any way to spare the rectangle permanently from getting 'flipped' away?
>
> So basically I am looking for a way to make the white rectangle part of the background
> (just as the initial
>
> black=BlackIndex(0);
> Screen('FillRect',w, black);
> Screen('Flip', w);
>
> causes the blackground to be black)
> though it should be possible to switch off / hide the white rectangle from time to time.
>
> I would be glad to hear any suggestion!
>
> Thanks,
>
> -Fabian Stelzer
>
Dear Mario,

thanks for your reply.
I need the 'white rectangle' to indicate an eye-tracker when to start tracking and when to
stop - via a photodiode attached on the lower left corner of the screen ;-)
I'll try if it works with redrawing the rectangle everytime...
I agree, other than that, this rectangle thing is a very strange wish to have.
Thanks anyways,

-Fabian

--- In psychtoolbox@yahoogroups.com, "Mario Kleiner" <mario.kleiner@t...> wrote:
>
> Dear Fabian,
>
> what you want (only clearing parts of the screen) is not possible and
> won't be in the future unless somebody can provide a very convincing
> reason for the need of such a function.
>
> But the obvious solution is to simply redraw your white rectangle after
> invocation of Screen('Flip')... -- What's wrong with that simple solution?
>
> Just for the record: There are three clearmodes...
>
> dontclear=2 -- The content of the backbuffer after Screen('Flip') is
> identical to the previous content of the frontbuffer -- the image that
> was on display *before* the Flip command is now available for overdrawing.
> This mode is the fastest - it takes 0.0 Milliseconds.
>
> dontclear=0 -- This is the default mode: The backbuffer is cleared to
> background color. Takes a bit of time, depending on display resolution
> and performance of your gfx-card maybe between 0.1 ms and 2 ms.
>
> dontclear=1 -- Keep content after Flip - This is the slowest method,
> because its implemented via making a backup copy of the buffer before
> Flip and then restore buffer from backup after flip. Can take from 1 ms
> up to multiple milliseconds. This mode is mostly meant for stimuli that
> are so complex to draw that redrawing them from scratch would cost
> much more time than the multiple milliseconds that dontclear=1 itself
> needs.
>
> dontclear=2 can be interesting if one overdraws a specific area of the
> screen after each Flip anyway, e.g., if you present a centered image
> that changes at each redraw. Then you could do:
>
> Screen('FillRect', win, 0); % Clear buffer with black.
> Screen('Flip', win); % Show blank screen.
> Screen('Flip', win); % Show blank screen, clear 2nd buffer.
>
> for i=1:trials
> % Overdraw stuff from last trial with new stuff from...
> % new trial. Needs special caution when using Alpha-
> % blending...
> ...
> % Flip buffers. Don't clear or restore anything...
> Screen('Flip', win, [], 2);
> end;
>
> best,
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "fabian_stelzer" <fabian_stelzer@y...> wrote:
> >
> > Dear Forum,
> >
> > I am using the latest release of the Psychtoolbox for Mac OS X.
> >
> > For the purpose of my experiment, it is important to have a white rectangle in the
lower
> > left corner during the presentation of the actual stimuli.
> > The actual stimuli are 'flipped' a lot, and while the rectangle mustn't be affected by
> those
> > 'Flip' commands, I 'flip' the rectangle as follows:
> >
> > Screen('Flip', w, [], 1); % where the last 'don't clear' parameter is set to '1'.
> >
> > to prevent it from being cleared.
> >
> > But: of course the next normal 'Flip' clears it and this is exactly what it should do to
all
> the
> > other graphical elements, but not to the rectangle.
> > Is there any way to spare the rectangle permanently from getting 'flipped' away?
> >
> > So basically I am looking for a way to make the white rectangle part of the
background
> > (just as the initial
> >
> > black=BlackIndex(0);
> > Screen('FillRect',w, black);
> > Screen('Flip', w);
> >
> > causes the blackground to be black)
> > though it should be possible to switch off / hide the white rectangle from time to
time.
> >
> > I would be glad to hear any suggestion!
> >
> > Thanks,
> >
> > -Fabian Stelzer
> >
>