user2214790
user2214790

Reputation: 21

DirectX program throw an exception when it is destroyed under window mode

The problem occurs when I try to play with one of the Rastertek DirectX 11 tutorials.

It works fine except that the program throws an exception when the window is destroyed:

Unhandled exception at 0x779715ee in FrustumCulling.exe: 0xC0000005: Access violation reading location 0xfeeeff5e.

it's tutorial 16 at http://www.rastertek.com/dx11tut16.html

The only modifications I made are:

In graphicsclass.h

const bool FULL_SCREEN = true //false;

and

SystemClass::InitializeWindows
{

...

m_hwnd = CreateWindowEx(WS_EX_APPWINDOW, m_applicationName, m_applicationName, 
            WS_OVERLAPPEDWINDOW,
            posX, posY, screenWidth, screenHeight, NULL, NULL, m_hinstance, NULL);

...

}

Upvotes: 1

Views: 415

Answers (1)

SlxS
SlxS

Reputation: 413

Is it possible you're still setting up your swapchain in fullscreen mode? When I was running into this issue, adding this to my DxClass' destructor solved it

if(_swapChain != nullptr)
{
            _swapChain->SetFullscreenState(false, NULL);  
            _swapChain->Release();
            _swapChain = nullptr;
}

As per one of the Rastertek comments in one of the tutorials, the swapchain has to have the fullscreen set to false prior to being released.

When you set up your DXGI_SWAP_CHAIN_DESC assure you are using swapChainDesc.Windowed = !FULL_SCREEN and not a literal bool value, and make sure you set FULL_SCREEN to false, FULL_SCREEN = true //false; wouldn't do that and shouldn't compile.

Upvotes: 1

Related Questions