psychopy.org | Reference | Downloads | Github

Unexpected problem with buffer output on flip

import numpy as np
import psychopy
from psychopy import visual, core, event, monitors, sound, clock

trials, moves, counter = 0, 0, 0

# Window
window = visual.Window(
    size=(1024, 768), fullscr=True, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True, 
    units='cm')

print(window.getActualFrameRate()) # b/w 59.7-60.3

# Start Page
text1 = visual.TextStim(window, font = "Arial", height =0.5)
text2 = visual.TextStim(window, font = "Arial", height =0.8)
text1.setColor(color = (1, 1, 1))
text1.setPos(newPos = (0,0))
text1.setText(
text = "Thank you for taking the time to participate in the experiemnt\n \
Instructions:\n \
xxxxxxxxxx" )

text2.setColor(color = (-1, -1, -1))
text2.setPos(newPos = (0, -7))
text2.setText(text = "press spacebar to proceed")
text1.draw()
text2.draw()
window.flip(clearBuffer = False) #Flip 1
core.wait(3.0)
window.flip() #Flip2
core.wait(3.0)

psychopy.event.waitKeys()

# Close Window & Quit all routines
window.close()
core.quit()

From what I understand, the two text stimuli i.e text1 and text2 are drawn to the back buffer initially and whether I use Flip1 with clearBuffer param taking either of the bool values shouldn’t matter as it is clearing the front buffer which is already empty. Next I want an empty screen to come out i.e the front buffer as nothing is drawn on it. Now when I perform Flip2, the expected output takes place when Flip1’s parameter takes the value “True” but the window does not go blank when the parameter is “False”. Can someone please explain this to me?

You are only ever drawing to the back buffer. Maybe the name of the .flip() command is a bit misleading, but you should think of it as flipping the content of the back buffer to the front buffer, not swapping the two buffers. i.e. the drawing of content is a one-way stream from the back to the front.

So .flip() blits the content of the back buffer to the front, overwriting whatever was there. By default we usually then also want the contents of the back buffer to be cleared, ready to start drawing again from scratch. In rare circumstances, you might want the content of the buffer preserved (with clearBuffer = False), so that you can do some sort of progressive drawing, or because you don’t want to update the content but do want the benefit of still actively adhering to the screen refresh cycle. But all of this only relates to the contents of the back buffer.

Hopefully this helps make sense of your code, which is behaving exactly as expected if you adopt that cognitive model. i.e. on the first .flip(), you leave the contents of the back buffer in place (with clearBuffer = False), so on the second .flip(), even though you haven’t done any more drawing, the old content gets sent once again to the front buffer.

1 Like