# Pyglet: How to use second screen's vsync

does anybody know if it's possible to use the vsync of the second monitor instead of the first one with pyglet?

I have 2 monitors, one running at 60Hz and the other at 120Hz. I want to be able to set my application on whatever monitors I have, and have the application use the monitor's rate to swap the buffers.

This needs to be cross platform.

I found this information... pyglet.window

But I was wondering if anybody knows a way...

vsync = True just means to wait with swapping buffers until the next vertical retrace, which is the point in time where a frame is completely drawn on the monitor, instead of somewhere halfway through, which can cause visible tearing during animations.

Enabling vsync (on whatever platform) will simply tell OpenGL to wait for the next retrace. It will do this with respect to the refresh rate of the screen, which means on a 120 Hz monitor it has 120 opportunities per second to swap buffers with vsync enabled (instead of 60 at 60 Hz).

So you don't need to do anything other than enable vsync and it'll just do the right thing depending on which screen you're rendering to.

See also the platform vendor documentation, e.g. NSOpenGLCPSwapInterval for OS X.

You can query the refresh rate of each screen using get_mode():

import pyglet
platform = pyglet.window.get_platform()
display = platform.get_default_display()
for screen in display.get_screens():
print(screen.get_mode().rate)