Scaling to fit different modes and resolutions


  • I'm wondering how to scale a DirectX app to fit the different modes and resolutions.  Right now, this is how my swap chain is set up:

    // Allocate a descriptor.
            DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0};
            swapChainDesc.Width = 1366;                                     // use automatic sizing
            swapChainDesc.Height = 768;
            swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;           // this is the most common swapchain format
            swapChainDesc.Stereo = false;
            swapChainDesc.SampleDesc.Count = 1;                          // don't use multi-sampling
            swapChainDesc.SampleDesc.Quality = 0;
            swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
            swapChainDesc.BufferCount = m_numBuffers;                    // use multiple buffering to enable flip
            swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
            swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // all Metro style apps must use this SwapEffect
            swapChainDesc.Flags = 0;

    This works excellent for scaling to different screen sizes, but when it comes to different aspect ratios this method ends up squishing the picture horribly. My question is how can I set the app so that when there's a different aspect ratio, the game will simply put black letterboxing around the top and bottom?

    Friday, October 26, 2012 5:01 PM