Skip to content

Commit 5e1c045

Browse files
mdcpeircej
mdc
authored andcommitted
BF: Change window switching logic to also bind the FBO if enabled.
1 parent c1ff68f commit 5e1c045

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

psychopy/visual/basevisual.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,9 +1151,7 @@ def draw(self):
11511151

11521152
def _selectWindow(self, win):
11531153
# don't call switch if it's already the curr window
1154-
if win != globalVars.currWindow and win.winType == 'pyglet':
1155-
win.winHandle.switch_to()
1156-
globalVars.currWindow = win
1154+
self.win._setCurrent()
11571155

11581156
def _updateList(self):
11591157
"""The user shouldn't need this method since it gets called

psychopy/visual/window.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,23 @@ def saveFrameIntervals(self, fileName=None, clear=True):
548548
self.frameIntervals = []
549549
self.frameClock.reset()
550550

551+
def _setCurrent(self):
552+
"""Make this window current.
553+
"""
554+
if self != globalVars.currWindow and self.winType == 'pyglet':
555+
self.winHandle.switch_to()
556+
globalVars.currWindow = win
557+
558+
# if we are using an FBO, bind it
559+
if self.useFBO:
560+
GL.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT,
561+
self.frameBuffer)
562+
GL.glReadBuffer(GL.GL_COLOR_ATTACHMENT0_EXT)
563+
GL.glDrawBuffer(GL.GL_COLOR_ATTACHMENT0_EXT)
564+
GL.glActiveTexture(GL.GL_TEXTURE0)
565+
GL.glBindTexture(GL.GL_TEXTURE_2D, 0)
566+
GL.glEnable(GL.GL_STENCIL_TEST)
567+
551568
def onResize(self, width, height):
552569
"""A default resize event handler.
553570

0 commit comments

Comments
 (0)