# A problem about  &quot;don&#39;t clear&quot; parameter in &quot;Flip&quot; function

**URL:** <https://psychtoolbox.discourse.group/t/a-problem-about-quot-don-39-t-clear-quot-parameter-in-quot-flip-quot-function/1779>\
**Category:** Uncategorized\
**Created:** [December 27, 2018, 10:24am UTC](https://psychtoolbox.discourse.group/t/a-problem-about-quot-don-39-t-clear-quot-parameter-in-quot-flip-quot-function/1779 "2018-12-27T10:24:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Ingling](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Allen\_Ingling](https://psychtoolbox.discourse.group/u/Allen_Ingling)\
**Post date:** [December 27, 2018, 10:24am UTC](https://psychtoolbox.discourse.group/t/a-problem-about-quot-don-39-t-clear-quot-parameter-in-quot-flip-quot-function/1779/1 "2018-12-27T10:24:35Z")

</div>

My goal is&nbsp; to "Flip" a moving object under a unaltered background. Firstly, I "flip" the background with the "don't clear" parameter as 1. Then I "flip" the moving object with&nbsp;"don't clear"&nbsp;parameter as 2 constantly in a "for" loop. However,&nbsp; the window showed many objects simultaneously. I want to show only one object at one time. How could I do that?&nbsp;

My psychtoolbox version is 3.0.14 - Flavor: beta. My pc system is win7-64bit.

For better discription my issue, I make an example code.&nbsp;

[window, rect] = Screen('Openwindow',0,255/2); %%open a window

Screen('FillRect', window,[125 0 0], [0.3\*rect(3),0.3\*rect(4),0.7\*rect(3),0.7\*rect(4)],2)%%&nbsp; a red background

Screen('Flip',window,0,1);%% add the red background to the window

WaitSecs(1);

Screen('FillRect', window,[0 125 0], [0.4\*rect(3),0.4\*rect(4),0.6\*rect(3),0.6\*rect(4)],2);% green object

Screen('Flip',window,0,2 );

WaitSecs(1);

Screen('FillRect', window,[125 125 0], [0.45\*rect(3),0.45\*rect(4),0.55\*rect(3),0.55\*rect(4)],2);% yellow

Screen('Flip',window,0,2 );&nbsp;

WaitSecs(1);

Screen('FillRect', window,[0 0 125], [0.47\*rect(3),0.47\*rect(4),0.52\*rect(3),0.52\*rect(4)],2);% blue

Screen('Flip',window,0,2 );

WaitSecs(1);&nbsp;

sca;

In my comprehension , the window will show only the red background and blue object at last.&nbsp;

But strangly, it show the red background, green and blue objects. I can't explain it. Why it gives green? Maybe I misunderstand the Flip don't clear parameter. I can't figure it out.

I really hope somebody could help me or give me some advices about the Flip framebuffer.

Thank you.

---

<div class="post-metadata">

**Author:** ![xrli2002](https://avatars.discourse-cdn.com/v4/letter/x/48db29/32.png) [@xrli2002](https://psychtoolbox.discourse.group/u/xrli2002)\
**Post date:** [December 27, 2018, 8:02pm UTC](https://psychtoolbox.discourse.group/t/a-problem-about-quot-don-39-t-clear-quot-parameter-in-quot-flip-quot-function/1779/2 "2018-12-27T20:02:36Z")

</div>

Your observation is expected, since the framebuffer is not cleared. For "moving" object, I think you have to choose clear buffer. As the help indicates, dontclear is for incremental drawing.

-Xiangrui

---

<div class="post-metadata">

**Author:** ![elladawu](https://avatars.discourse-cdn.com/v4/letter/e/71c47a/32.png) [@elladawu](https://psychtoolbox.discourse.group/u/elladawu)\
**Post date:** [December 27, 2018, 11:12pm UTC](https://psychtoolbox.discourse.group/t/a-problem-about-quot-don-39-t-clear-quot-parameter-in-quot-flip-quot-function/1779/3 "2018-12-27T23:12:41Z")

</div>

as mentioned, the behaviour you are seeing is expected.

  

if your background is simple, just redraw it in the loop. if the background is complex, then you can pre-draw it as a texture and reload the texture inside the loop instead.
