A way to listen window mode changes WndProc

182 Views Asked by At

I'd like to refresh my swap chain when my game switches from windowed to fullscreen and vice versa, for the moment I only found uMsg == WM_SIZE which but it's not optimal, fullscreen to borderless doesn't work unfortunately.... Is there another message ? Thanks

1

There are 1 best solutions below

0
Chuck Walbourn On

For "fullscreen" vs. "windowed" handling using DXGI, there are two basic approaches:

  1. Let DXGI do it for you via DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH.

  2. Use the flag DXGI_MWA_NO_WINDOW_CHANGES and handle it yourself. You in fact do use WM_SIZE to determine the changes. You may also want to use DXGI_MWA_NO_ALT_ENTER and handle the ALT+ENTER shortcut in your WndProc.

See Microsoft Docs: DirectX Graphics Infrastructure (DXGI) Best Practices.

For windowed mode, a challenge with WM_SIZE is that as the 'rubberband' rectangle is adjusted you get a lot of these messages, and resizing the backbuffer is not that fast. One solution here is to use WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE so you can pause the resizing until it's completed.

See GitHub a detailed WndProc implementation.

One final point: There are actually several definitions for 'fullscreen'. See this blog post.