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.