diff --git a/psychopy/tests/test_all_visual/flips.py b/psychopy/tests/test_all_visual/flips.py new file mode 100644 index 00000000000..0f79ab31268 --- /dev/null +++ b/psychopy/tests/test_all_visual/flips.py @@ -0,0 +1,26 @@ +# test window.viewScale and .viewPos simultaneous and negative-going values +# the green square/rect should move clockwise around the text + +from psychopy import visual, event + +win = visual.Window(size=(400,400), units='pix') #, viewOri=30) test viewOri here + +v = [(1,1),(1,-1),(-1,-1),(-1,1)] # vertices to use = square +n = 30 # size of the square +pimg= (n,n) # position for the image +pgrn = (-n,-n) # position for green square + +for offset in [(0,0), (-.4,0)]: + win.viewPos = offset + for scale in [[1,1], # normal: green at lower left + [1,-1], # mirror vert only: green appears to move up, text mirrored + [-1,-1], # mirror horiz & vert: green appears to move right, text normal but upside down + [-1,1], # mirror horiz only: green appears to move down, text mirrored + [2,2],[2,-2],[-2,-2],[-2,2]]: # same, but both larger + win.viewScale = scale + grn = visual.ShapeStim(win, vertices=v, pos=pgrn, size=n, fillColor='darkgreen') + img = visual.ImageStim(win, image='s.png', pos=pimg) + grn.draw() + img.draw() + win.flip() + event.waitKeys() \ No newline at end of file diff --git a/psychopy/tests/test_all_visual/s.png b/psychopy/tests/test_all_visual/s.png new file mode 100644 index 00000000000..59f9927648e Binary files /dev/null and b/psychopy/tests/test_all_visual/s.png differ diff --git a/psychopy/visual/window.py b/psychopy/visual/window.py index aa1fda52282..5040bf0fb79 100644 --- a/psychopy/visual/window.py +++ b/psychopy/visual/window.py @@ -609,15 +609,13 @@ def flip(self, clearBuffer=True): if stencilOn: GL.glEnable(GL.GL_STENCIL_TEST) #rescale/reposition view of the window + GL.glMatrixMode(GL.GL_MODELVIEW) + GL.glLoadIdentity() if self.viewScale is not None: - GL.glMatrixMode(GL.GL_PROJECTION) - GL.glLoadIdentity() GL.glOrtho(-1, 1, -1, 1, -1, 1) GL.glScalef(self.viewScale[0], self.viewScale[1], 1) scale = self.viewScale else: - GL.glMatrixMode(GL.GL_MODELVIEW) - GL.glLoadIdentity() scale = [1, 1] if self.viewPos is not None: @@ -626,7 +624,13 @@ def flip(self, clearBuffer=True): GL.glTranslatef(norm_rf_pos_x, norm_rf_pos_y, 0.0) if self.viewOri is not None: - GL.glRotatef(self.viewOri, 0.0, 0.0, -1.0) + # the logic below for flip is partially correct, but does not handle viewPos + flip = 1 + if self.viewScale is not None: + _f = self.viewScale[0] * self.viewScale[1] + if _f < 0: + flip = -1 + GL.glRotatef(flip * self.viewOri, 0.0, 0.0, -1.0) #reset returned buffer for next frame self._endOfFlip(clearBuffer)