Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectX9 window resize in runtime without device reset

In: C++\Win32 application (not in fullscreen)\DX9

How can i redraw window content during resize fast and nice enough? Resize == user drag window border.

Different approaches:

  • Reset device on each WM_SIZE\WM_PAINT. Adequate resolution, but black stripes appears on fast upscale.
  • Reset device on WM_EXITSIZEMOVE and pause rendering on WM_ENTERSIZEMOVE. Best speed, but to ugly ~ black stripes during resize.
  • Can't find out how to use dx9's swapchain in this case
  • Keep rendering and swapping buffers during resize; reset on WM_EXITSIZEMOVE. Exactly what occurs in official demos from 2010 SDK. Looks fast and acceptable nice. But [suddenly] on slow computer black stripes reappeared. Thin and rare, but real. Actually, thats very strange: synchronous rendering and Present(,,,) on every WM_SIZE and\or WM_PAINT excludes that at first glance. And at the second. Perhaps i dont understand something important?

So, when last method failed i decided to ask here. Is that possible somehow make dx9 surface securely glued to window border. No black stripes. Prefer to slow scale speed down, but sync it somehow with DX.

like image 554
mjollneer Avatar asked Oct 25 '13 17:10

mjollneer


1 Answers

I allocate a backbuffer large enough for the maximum client size of the window, and set a viewport that matches the current window client size on WM_SIZE. Then I render to resp. present from that viewport only. This way no device reset is required.

like image 92
cdoubleplusgood Avatar answered Nov 11 '22 05:11

cdoubleplusgood