Skip to content

Commit a1c29d3

Browse files
committed
BF: adding a potential fix to the pyglet shadow_window issue
Some graphics cards (or their drivers) don't support OpenGL shadow windows, which pyglet uses to bind textures etc. Turning it off should only affect people that need multiple windows, with stimuli shared between them.
1 parent ae283ce commit a1c29d3

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

psychopy/visual/window.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,12 +1469,29 @@ def _setupPyglet(self):
14691469
style = None
14701470
else:
14711471
style = 'borderless'
1472-
self.winHandle = pyglet.window.Window(width=w, height=h,
1473-
caption="PsychoPy",
1474-
fullscreen=self._isFullScr,
1475-
config=config,
1476-
screen=thisScreen,
1477-
style=style)
1472+
try:
1473+
self.winHandle = pyglet.window.Window(
1474+
width=w, height=h,
1475+
caption="PsychoPy",
1476+
fullscreen=self._isFullScr,
1477+
config=config,
1478+
screen=thisScreen,
1479+
style=style)
1480+
except pyglet.gl.ContextException:
1481+
# turn off the shadow window an try again
1482+
pyglet.options['shadow_window'] = False
1483+
self.winHandle = pyglet.window.Window(
1484+
width=w, height=h,
1485+
caption="PsychoPy",
1486+
fullscreen=self._isFullScr,
1487+
config=config,
1488+
screen=thisScreen,
1489+
style=style)
1490+
logging.warning("Pyglet shadow_window has been turned off. This is "
1491+
"only an issue for you if you need multiple "
1492+
"stimulus windows, in which case update your "
1493+
"graphics card and/or graphics drivers.")
1494+
14781495
if sys.platform == 'win32':
14791496
# pyHook window hwnd maps to:
14801497
# pyglet 1.14 -> window._hwnd

0 commit comments

Comments
 (0)