c++directxfullscreendirectx-11directxtk

D3D11 DirectXTK Spritebatch fullscreen issues


I am working on a low resolution 2D game using the DirectXTK and Spritebatch. Everything works fine in windowed mode, however whenever I start or switch to fullscreen the image is blurred to stretch the backbuffer to fit the screen.

I Initialise the device and swap chain with these settings:

DXGI_SWAP_CHAIN_DESC scd = { 0 };
scd.BufferCount = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.BufferDesc.Width = width;
scd.BufferDesc.Height = height;
scd.BufferDesc.RefreshRate.Numerator = 0;
scd.BufferDesc.RefreshRate.Denominator = 0;
scd.BufferDesc.Scaling = DXGI_MODE_SCALING_CENTERED;
scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
scd.OutputWindow = m_hWnd;
scd.SampleDesc.Count = 1;
scd.SampleDesc.Quality = 0;
scd.Windowed = !m_fullscreen;
scd.Flags = 0;
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;`

And the sampler state is set up as follows:

D3D11_SAMPLER_DESC sd = {};
sd.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
sd.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
sd.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
sd.MaxAnisotropy = (m_D3DDevice->GetFeatureLevel() > D3D_FEATURE_LEVEL_9_1)?D3D11_MAX_MAXANISOTROPY:2;
sd.MaxLOD = D3D11_FLOAT32_MAX;
sd.ComparisonFunc = D3D11_COMPARISON_NEVER;

In the windows message handler I recreate the resources when the window size changes, if I use the new window size as the backbuffer dimensions or original game dimensions the game is blurred either way.

Does anyone know how to resolve this issue? Can Chuck Walbourn user:3780494 shed some light on the situation?

Thank you so much.


Solution

  • Thank you to Chuck Walbourn for pointing me to the DirectXTK templates.

    After changing my Graphics class to match the template, the full screen on longer blurs.

    Although I am not changing the backbuffer screen resolution It needs to be unchanged so that the low resolution is stretched to fit the window. If I change the backbuffer it is difficult to see the game because it is then rendered so small.

    It appears the reason the fullscreen mode is not blurred when using the template is because it is actually borderless windowed mode and not exclusive fullscreen.