psychopy.org | Reference | Downloads | Github

All elements clipped at a certain distance from the edge?

Hi all, so bear with me, I just started using PsychoPy!

Very simple issue; I want to show a TextStim near the top of the window (to act as a title). It seems to be clipped off once it gets to a certain distance:

image

So of course I could just move it lower and change everything accordingly, but it would be great if I could increase that boundary somehow.
Anyone know what’s going on here?

OS: Ubuntu 16.04
PsychoPy version: 3.1.2
Standard Standalone? (y/n): Yes (I think)

Thanks! :slight_smile:

Edit: A colleague recommended I move to pure coding instead of the Builder. I’m comfortable with Python, so I’m changing the topic to Coding.

Hi @adam_coyne, its hard to know without seeing your code. If you are using an Aperture component to control where text can be presented, you could try making the aperture larger. If not, would you mind sharing a minimal working example? E.g. one slider and the text component.

So I think I may have found a bug. I was preparing a working example with a single routine, and I found that without other routines before the one pictured the problem didn’t occur. It seems to be clipped to the edges of the Form component I used in the previous one.

So far I haven’t messed around with the code, here’s two examples generated by the Builder so I’m sure it’s fairly standard:
testingAWN_1routine.py (18.4 KB) testingAWN_2routines.py (22.8 KB)

For me, the 1routine file displays fine, but the same routine with the Form preceding it cuts off the edges like I described.

Here’s a quick view of how it looks.

Single routine:


The same routine, after another with a Form component:

Also I realised you’ll need form questions for the 2routines file, here’s mine: ssq.xlsx (5.3 KB)

1 Like

Yes, it is related to the aperture that is being used in the Form component, however I cannot recreate this error from Builder or Coder. Would you mind also sending me your psyexp file?

Here’s the experiment file. You’ll also need the ssq.xlsx file again.
2routines.psyexp (38.4 KB)
Thanks for all your help!

@adam_coyne, there is a fix but this involves changing the source code. If you are happy to output your code into Coder and run the study from Coder, you just need to set the useFBO param in the Window component to False:

# Setup the Window
win = visual.Window(
    size=[1920, 1080], fullscr=True, screen=0, 
    winType='pyglet', allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=False,  # Change useFBO to False 
    units='height')

If you are happy to change the source code, go to the psychopy>visual folder and in the `window.py" file and…

replace line 690

with the following:

if GL.glIsEnabled(GL.GL_STENCIL_TEST):
    GL.glEnable(GL.GL_STENCIL_TEST)
2 Likes

So I tried changing the source code, however I don’t seem to have the same window.py as the one you linked. Here’s a snippet of my version where I found the only reference to GL.glEnable(GL.GL_STENCIL_TEST) (around line 790):

        flipThisFrame = self._startOfFlip()
        self.resetEyeTransform(False)  # reset transformations
        if self.useFBO:
            if flipThisFrame:
                self._prepareFBOrender()
                # need blit the framebuffer object to the actual back buffer

                # unbind the framebuffer as the render target
                GL.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0)
                GL.glDisable(GL.GL_BLEND)
                stencilOn = GL.glIsEnabled(GL.GL_STENCIL_TEST)
                GL.glDisable(GL.GL_STENCIL_TEST)

                if self.bits is not None:
                    self.bits._prepareFBOrender()

                # before flipping need to copy the renderBuffer to the
                # frameBuffer
                GL.glActiveTexture(GL.GL_TEXTURE0)
                GL.glEnable(GL.GL_TEXTURE_2D)
                GL.glBindTexture(GL.GL_TEXTURE_2D, self.frameTexture)
                GL.glColor3f(1.0, 1.0, 1.0)  # glColor multiplies with texture
                GL.glColorMask(True, True, True, True)

                self._renderFBO()

                GL.glEnable(GL.GL_BLEND)
                self._finishFBOrender()

        # call this before flip() whether FBO was used or not
        self._afterFBOrender()

        self.backend.swapBuffers(flipThisFrame)
        if self.useFBO:
            if flipThisFrame:
                # set rendering back to the framebuffer object
                GL.glBindFramebufferEXT(
                    GL.GL_FRAMEBUFFER_EXT, self.frameBuffer)
                GL.glReadBuffer(GL.GL_COLOR_ATTACHMENT0_EXT)
                GL.glDrawBuffer(GL.GL_COLOR_ATTACHMENT0_EXT)
                # set to no active rendering texture
                GL.glActiveTexture(GL.GL_TEXTURE0)
                GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
                if stencilOn:
                    GL.glEnable(GL.GL_STENCIL_TEST)

It seems to already include the stencil check you mentioned; I tried playing around with it, inverting the condition, removing the if statement, removing the glEnable line entirely, but it didn’t stop the issue. I see you’re a contributor on the Github @dvbridges, would you think this is a bug that should be reported?

Setting useFBO=True in the Coder did solve the problem however, so I’m happy meanwhile :slightly_smiling_face:
Thanks for all your time!

Ah I see, my fix only works on the GitHub repository as the changes have not been released yet (the fix has been posted here). You would instead go into the psychopy\visual\backends folder and make the changes to the pygletbackend.py file, line 291.

1 Like

Beautiful! All fixed, with the default project code. Thanks!