Win32, OpenGL, VSync and multiple monitors with different refresh rates

My game engine takes a simplistic approach to supporting multiple windows with a single OpenGL context in the following way:

Activate OpenGL context on window 1  
Draw scene in to window 1

Activate OpenGL context on window 2  
Draw scene in to window 2

Activate OpenGL context on window 3  
Draw scene in to window 3

For all Windows

This works fine with monitors of the same refresh rate (with VSync on or off), and now I’m experimenting with monitors of different refresh rates. With V-Sync disabled, as long as the engine can produce enough frames, a window on a higher refresh rate monitor won’t get slowed down by a window on a slower refresh rate monitor, as SwapBuffers doesn’t block. With V-Sync enabled, SwapBuffers will sync to the slowest monitor and windows on faster monitors will get slowed down.

If there any way of fixing this without resorting to a thread and OpenGL context for each window? I was thinking along the lines of a non-blocking SwapBuffers and checking if a window is going through a swap, and if not then swapping it’s buffers or something?

My question may be daft, but have you considered to run each window/OpenGL context in a different thread?

I don’t think there is a way in OpenGL or wgl or their extension to help you here.

The only thing that should work is triple-buffering. In theory the swap should not block if triple-buffering and VSync is enabled. But of course this is a vendor/implementation dependent thing, and can’t be controlled via gl or wgl, as far as I know. And at worst you’ll end up rendering frames that won’t be displayed.

Are you working on Windows VISTA/7/8? If so, you may experiment with turning off Aero ( Desktop Window Manager Session Manager Service ) else the whole desktop might be composited in the lowest frame rate?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.