I have a GUI written using wxPython that contains two GLCanvas
es, a 'display' canvas and a 'preview' canvas onto which I am drawing some very simple geometry using PyOpenGL. The 'preview' and 'display' canvases display the contents of the same framebuffer:
I need both of these canvases to be updated synchronously at a consistent framerate with no tearing.
So far I have just been calling
self.SetCurrent()
# draw stuff...
self.SwapBuffers()
for both the preview and display canvases within my rendering loop. This works reasonably well provided that I disable vsync in my driver settings.
However, if I enable vsync my framerate drops to ~30Hz, half the vertical refresh rate of my display. Presumably this is because the execution of the rendering loop stalls at each SwapBuffers()
call waiting for the next vertical refresh - if I comment out one of the two SwapBuffers()
calls, my framerate goes back up to 60Hz, but then of course only one of my canvases gets updated.
What I'd really like is for both of my canvases to be updated synchronously, once per vsync interval. Is there any way that I can achieve this using the wx.glcanvas.GLCanvas
class?
SwapBuffers()
method of awx.glcanvas.GLCanvas
object seems to implicitly block execution until the next vsync. I'm not currently aware of any way that I can callSwapBuffers
without also waiting for the next vertical refresh, aside from just disabling vsync entirely in my driver settings. – Crim{wgl|glX}SwapInterval
to set the swap interval for the first, synching SwapBuffers to 1, and then right after the synching SwapBuffers returns set the swap interval to 0 and do the other SwapBuffers. – Concrescence{wgl|glX}SwapInterval
like datenwolf said. I just figured wx was managing your OpenGL context for you so it would have a more portable way of doing the same thing. – FaucalglXSwapInterval
to reset the swap interval on the fly works beautifully. If you write it up as an answer I'd be happy to accept. – Crim