# dontclear in flip command

**URL:** <https://psychtoolbox.discourse.group/t/dontclear-in-flip-command/504>\
**Category:** Uncategorized\
**Created:** [June 8, 2011, 12:43pm UTC](https://psychtoolbox.discourse.group/t/dontclear-in-flip-command/504 "2011-06-08T12:43:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrispaffen](https://avatars.discourse-cdn.com/v4/letter/c/85f322/32.png) [@chrispaffen](https://psychtoolbox.discourse.group/u/chrispaffen)\
**Post date:** [June 8, 2011, 12:43pm UTC](https://psychtoolbox.discourse.group/t/dontclear-in-flip-command/504/1 "2011-06-08T12:43:51Z")

</div>

Hi  
  
Im trying to draw squares with a temporal frequency of say 10 Hz without clearing the screen.   
I get incremental drawing of images (so that works), but not at the frequency I want (it's much slower).   
  
I use something like:  
  
tf = 10;  
while 1  
  
 ...  
  
 Screen('FillRect', w,RGB,squareRect);  
 t0 = Screen('Flip', w,t0+(1/tf),1);  
end  
  
Can anyone help?

---

<div class="post-metadata">

**Author:** ![mariokleiner](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@mariokleiner](https://psychtoolbox.discourse.group/u/mariokleiner)\
**Post date:** [June 9, 2011, 1:50pm UTC](https://psychtoolbox.discourse.group/t/dontclear-in-flip-command/504/2 "2011-06-09T13:50:21Z")

</div>

Jap. Also read through the pdf's in the PsychDocumentation folder for timing tips.  
  
If it is really much slower then it is likely a graphics driver bug.  
  
Try replacing in your code:  
  
PsychImaging('PrepareConfiguration');  
PsychImaging('AddTask', 'General', 'UseVirtualFramebuffer');  
win = PsychImaging('OpenWindow', ....);  
  
instead of  
  
win = Screen('OpenWindow', ....);  
  
This switches to a different implementation, which should allow to circumvent the graphics driver bug - and it is more efficient for the dontclear=1 mode anyway.  
  
-mario  
  
  

> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "xrli2002" \<xrli2002@...\> wrote:  
> \>  
> \> If it is much slower, something may go wrong. But you need do something like this to avoid single framae delay:  
> \> hz=Screen('NominalFrameRate',w);  
> \> interval=1/tf-1/hz/2; % interval with half frame shorter  
> \>   
> \> Then in the loop:  
> \>   
> \> t0 = Screen('Flip', w, t0+interval, 1);  
> \>   
> \> -Xiangrui  
> \>   
> \> --- In [psychtoolbox@yahoogroups.com](mailto:psychtoolbox@yahoogroups.com), "Chris" \<chrispaffen@\> wrote:  
> \> \>  
> \> \> Hi  
> \> \>   
> \> \> Im trying to draw squares with a temporal frequency of say 10 Hz without clearing the screen.   
> \> \> I get incremental drawing of images (so that works), but not at the frequency I want (it's much slower).   
> \> \>   
> \> \> I use something like:  
> \> \>   
> \> \> tf = 10;  
> \> \> while 1  
> \> \>   
> \> \> ...  
> \> \>   
> \> \> Screen('FillRect', w,RGB,squareRect);  
> \> \> t0 = Screen('Flip', w,t0+(1/tf),1);  
> \> \> end  
> \> \>   
> \> \> Can anyone help?  
> \> \>  
> \>
