How to enable VSYNC in a D3D windowed application?

So, I am using D3D in a windowed application.

I enabled D3D with the following options:

windowed: true;
backbufferformat: D3DFMT_X8R8G8B8;
presentinterval: D3DPRESENT_INTERVAL_ONE;
swapeffect: DISCARD

Each time OnPaint is called, I render the image to the buffer and present it in the foreground.

As far as I know (and so MSDN says), as soon as I install D3DPRESENT_INTERVAL_ONE, vsync will work.

But in this case, the image branches when dragged horizontally.

(It seems that the image shows a line, the image below the line is displayed on the monitor, and the above part).

Some sites say that D3DPRESENT_INTERVAL_ONE will not work in windowed applications.

How to enable vsync?

p.s. , D3D vsync , , , , . , .

+3
5

, D3D9? . D3DPRESENT_PARAMS:

if (bVysncEnabled)
{
    presentParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
    presentParams.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
}
else
{
    presentParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
    presentParams.FullScreen_RefreshRateInHz = 0;
}

, GDI, vsync, , . , .

+3

vsync , . , , ... .

0

vsynced d3d, , aero WinVista Win7, .

0

:: OnPaint? , , , :: OnPaint, .

, :: OnPaint , . , , RenderPresent D3D WAIT, , :: OnPaint !

, , vsync . DirectX 9 Win XP .

Oh, and last but not least, if you have multiple displays connected, make sure vsync is with the actual display that your window represents. It seems more complicated.

0
source

Source: https://habr.com/ru/post/1769149/


All Articles