View Full Version : vsync from secondary monitor

02-16-2012, 12:49 PM
Hey all,

Does anyone have experience with synchronizing an OpenGL application to a secondary display's vsync? I'm using wglSwapIntervalEXT(1), but from what I can tell that only ties into the primary monitor's vsync.

My OpenGL program only runs in one display (the projector), so I could just swap primary/secondary displays from the Win7 resolution settings window. That's what I'm doing now as a workaround, but it is really tedious and I'd like to get this working in code. Any ideas are welcome.

my setup:
NVIDIA Quadro 4000
Primary monitor: 1440x900 @ 60Hz
Secondary monitor: 1024x768 @ 60Hz


02-17-2012, 08:11 AM
Update on this after running some more tests this morning.

I spliced out the vsync wires from the VGA cables. I plugged the vsync wires into an oscilloscope, and confirmed that despite the fact that the vsyncs are set to 60Hz, one is actually slightly different than the other (~59Hz). That causes the two vsync signals to drift apart from each other, which causes the graphical glitches that I'm seeing.

At that point I tried playing around with different resolution settings in Windows 7 to see if I could keep the two vsyncs from drifting. I was able to keep them from drifting by setting the two monitor's resolution to the same width and height (1024x768). This also fixed the graphical glitches in my OpenGL application. Unfortunately it doesn't really help since I need both displays to have different resolutions, but I thought I'd mention this as a possible workaround in case someone else is having a similar problem.

02-17-2012, 02:16 PM
I frequently see 59 and 60 Hz being suggested for HD resolutions on LCD screens, be sure to select 60Hz for both screens.

EDIT: rereading your post apparently it is already the case... Can you try 59Hz on both ?

02-22-2012, 06:52 AM
I can only set 60Hz and 75Hz from each monitor's advanced settings window. Is there a win32 function to set the monitor's frequency that would let me specify 59Hz?

Some background info so that you know why I care so much about the vsync signal: I'm trying to use OpenGL to project a series of images on an object and then capture each frame with a gigabit ethernet camera. I'm then taking those images and reconstructing a 3D model of the object. This works fine if the projector is the only display attached to the computer, but it does not work with a dual monitor setup. The images come back with ghosts of other frames in them, which ultimately ruins the 3D model. From what I've been able to tell from debugging it looks like the program is hooking into the wrong vsync signal and there isn't any way around that in Windows 7 without swapping the primary/secondary display each time.

03-01-2012, 09:02 AM
I sort of solved this problem by flipping the monitors in code before and after running my application using the ChangeDisplaySettingsEx win32 method. That's real rough, because all the icons and programs move to the other desktop, and sometimes they don't move back to the right spot when the program ends.

I've read some articles that suggest that DirectX may be able to synchronize with the seconary monitor's vsync. Maybe I should be using DirectX instead of OpenGL for this, although I'd really hate to have to rewrite everything. :(

11-02-2012, 05:33 PM
It took me a while to figure this out, but simply disabling the "aero" features in Windows 7 worked for me.
FWIW, I'm using an LCD (locked to 60hz) for coding, and a CRT (running at over 100hz) to display fullscreen graphics for visual psychophysics.