c++ - How to Change Window Size in DirectX 11 Desktop Application -
I am writing a DirectX 11 shader program based on a tutorial in this MSDN link:
When I run it, it's in full screen. Changing the Swap chain size does not necessarily change the window size. Is there any way to resize the window? I just want to make a window in a certain shape and if it is to cover the entire screen, then I want to put it on a full screen.
I can get the HDND IDXGIG from SWAP series with Patch 1: GetHwnd way. Could it be useful for the size of the handle window?
The same code can be found here:
The original handling window is to update your window process to handle WM_SIZE to change the size for Direct3D 11 in Win32 desktop apps, but you have to deal with many cases Need for
LRESULT callback WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {static bool s_in_sizemove = false; Static bool s_minimized = false; Switch (message) {... WM_SIZE: if (wParam == SIZE_MINIMIZED) {// window (you probably have to suspend the application) if (! S_minimized) was minimized {s_minimized true =; }} And if (s_minimized) {// window was reduced and now it has been restored (resume suspension) s_minimized = false; } Else if (! S_in_sizemove) {// This is where you need to change the size of Swapchain to maximize) or break; Case WM_ENTERSIZEMOVE: // We want to avoid trying to change the size of the swapchain because the user changes the size of 'rubber band' s_in_sizemove = true; break; Case WM_EXITSIZEMOVE: s_in_sizemove = false; // This is the second place where you can resize swapchain after the user closes using 'rubber-band' brake; Case WM_GETMINMAXINFO: {// We want to prevent window from setting too small auto information = reinterpret_cast & lt; MINMAXINFO * & gt; (LParam); Info-gt; PtMinTrackSize.x = 320; Info-gt; PtMinTrackSize.y = 200; } break; ... Direct3D to swapchain size: with nulls to exit
- call
ID3D11DeviceContext :: OMSetRenderTargetsTargeting and any depth / stencil buffer. - Release your render target view and depth / stencil view, and any other reference to the original back buffer or depth / stencil buffer.
- Code> D3D11DeviceContext :: Flush call those changes
IDXGISwapChain :: ResizeBuffers to change the size of the new backbuffer - for. Make sure you have the answer to
DXGI_ERROR_DEVICE_REMOVEDandDXGI_ERROR_DEVICE_RESETfailures - do the same setup again as you did for the new size initially Was:. To create the target view of the new back buffer, create a new depth stencil view for your depth / stencil buffer that matches the new backform size (optional), and resets the viewport size.
Due to this process some assumptions about the application, it was left for the simplicity of the Win32 desktop tutorial. This case is handled for Direct 3D Win32 game templates and Windows Store DirectX app templates and Windows Phone DirectX app templates.
There is no such thing as 'full-screen exclusive mode' for the Windows Store app or Windows Phone app, so those templates do not apply it to Win32 Desktop Tutorial and for the Direct3D Win32 game template, I do not have to use the following to deal with it:
dxgiFactory-> MakeWindowAssociation (hWnd, DXGI_MWA_NO_ALT_ENTER); I want to come back again to expand the Direct3D Win32 game template to support full screen exclusive mode, but I have not found it yet.
Comments
Post a Comment