IDirect3DDevice9Ex windowed mode resize without a reset

I recently encountered an issue related to resizing internal DirectX9 overlay. Doing a full device reset on a window move or resize is too slow and did not seemed to be an appropriate way to do it.

The issue occurred when a target window was changed from windowed mode to borderless mode. The drawn lines did not shift according to the resolution.

I needed to find a solution on how to do DirectX9 window resize in runtime without device reset.

C++
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.

typedef struct
{
IDirect3D9Ex* object;
IDirect3DDevice9Ex* device;
D3DPRESENT_PARAMETERS param;
ID3DXFont* font;
ID3DXFont* fontWarning;
ID3DXLine* line;
} DX;

extern DX DX9;

The solution was to use the following D3DPRESENT PARAMETERS:

DX9.param.Windowed = true;
DX9.param.BackBufferFormat = D3DFMT_A8R8G8B8;
DX9.param.BackBufferWidth = 0;
DX9.param.BackBufferHeight = 0;
DX9.param.EnableAutoDepthStencil = true;
DX9.param.AutoDepthStencilFormat = D3DFMT_D16;
DX9.param.MultiSampleQuality = D3DMULTISAMPLE_NONE;
DX9.param.SwapEffect = D3DSWAPEFFECT_DISCARD;
DX9.param.hDeviceWindow = overlay.hwnd;
DX9.param.FullScreen_RefreshRateInHz = 0;
DX9.param.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
DX9.param.Flags = 0;

The most important part:

DX9.device->BeginScene();
// Render your ESP whatever here ...
DX9.device->EndScene();

RECT rect = { 0, 0, overlay.width, overlay.height };
DX9.device->PresentEx(&rect, &rect, overlay.hwnd, 0, 0);

DX9.device->Clear(0, 0, D3DCLEAR_TARGET, 0, 1.0f, 0);




Resize works just fine if I start a process in borderless mode and switch back to windowed mode. Doing other way does not work unless I reset the device. If anyone knows a proper solution. Feel free to write a comment. Thanks.
#863
Title:
Administrator
07/13/2020 15:21 - 1622 days 4 hours 13 minutes
#863
If you nee to have higher D3D overlay frame rate than 60FPS. You need to disable vertical sync.

1.

DX9.param.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Disable vertical sync (v-sync)



Post a comment

Registered users do not have to enter captcha. A line in the code tag is currently limited to maxium of 160 characters.
Posting guidelines: You may not post any personal information. When you report an issue: Always mention which version and operating system and briefly describe the issue. Any support request post that does not include this information will be removed as spam without a reply.
Title
Tags You may use the following tags: [QUOTE] [/QUOTE] [B] [/B] [URL] [/URL] [CODE] [/CODE]
Captcha Please enter the text you see (case insensitive). The listed characters must be entered clockwise starting from twelve o'clock.
Comments are moderated Y