Switch swapchain to windowed mode

782 views Asked by At

I need to release the swapchain but looks like it needs to be put it back in windowed mode.

DXGI ERROR: IDXGISwapChain::Release: Swapchain Released while fullscreen. Switch it to the windowed state first. [ MISCELLANEOUS ERROR #66: ]

Anyone knows the simplest way to accomplish this?

1

There are 1 answers

0
rashmatash On BEST ANSWER

To release a swap chain, you should do two things. First, release the render target view and depth/stencil view (if there is one) which are attached to the swap chain. Second put the swap chain in windowed mode:

// Releases the swap chain and all resources that are attached to it.    
void ReleaseSwapChain()
{
    ReleaseDefaultRTVAndDSV();

    if ( pSwapChain )
    {
        pSwapChain->SetFullscreenState( false, nullptr );
        pSwapChain->Release();
        pSwapChain = nullptr;
    }
}