Question

I have a GUI written using wxPython that contains two GLCanvases, 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:

enter image description here

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?

Was it helpful?

Solution

What Andon implied in his comment is, that you use {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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top