I’m writing a sort of CAD application, and I have a problem with lines “following” the mouse when the DWM is active (other CAD applications seems to have it too).
The problem can be simplified like this:
I render a line with the end point following the “current mouse position”. Without the DWM, if I enable vsync it renders at 60FPS, if I disable it it renders at 400FPS. The line extreme always UNDER the mouse,in both cases.
When I enable the composition in Vista/Win7, the line is delayed in respect to the mouse, there’s a noticeable lag between the mouse move and the line following it. Since WDM is on, the vsync is always active, and the “effective” present-on-video rate is at most 60FPS (on my screen).
In reality,using WDMGetTimingInfo I find that the effective refresh rate is 35FPS.
This causes the line to be always behind the actual mouse position, since there’s a delay from when I call SwapBuffer and when the DWM updates the video.
I already tryed to use Single Buffering, to drop the framerate, to adjust the DWM settings but without luck. The only solution is to disable the DWM. From what I understand this problem would be present using DirectX too, but I’m not sure at 100%
This effect is annoying in particular when the user draws rubber band lines.
I’ve tested a bunch of CADs and a lot have this problem too. But, for example, Google Sketchup doesn’t have this is issue, since the mouse is always responsive. Rhino on the other hand has it (tryed the v4 demo). Both use OpenGL.
So I guess this can be resolved anyhow.
There should be a way to force the DWM to repaint… at least the OpenGL window.
Any advice to give?