Esempio n. 1
0
// Actually destroy all 'global' resource handling objects, all asset handlers,
// the DX context, and everything EXCEPT the window
//-----------------------------------------------------------------------------
void CPUT_DX11::ShutdownAndDestroy()
{
    // make sure no more rendering can happen
    mbShutdown = true;

    // call the user's OnShutdown code
    Shutdown();
    CPUTInputLayoutCacheDX11::DeleteInputLayoutCache();
    CPUTAssetLibraryDX11::DeleteAssetLibrary();
    CPUTGuiControllerDX11::DeleteController();

// #ifdef _DEBUG
#if 0
    ID3D11Debug *pDebug;
    mpD3dDevice->QueryInterface(IID_ID3D11Debug, (VOID**)(&pDebug));
    if( pDebug )
    {
        pDebug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
        pDebug->Release();
    }
#endif
    CPUTOSServices::DeleteOSServices();

    // Tell the window layer to post a close-window message to OS
    // and stop the message pump
    mpWindow->Destroy();

    HEAPCHECK;
}
Esempio n. 2
0
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) {
	DBG_UNREFERENCED_PARAMETER(hPrevInstance);
	DBG_UNREFERENCED_PARAMETER(lpCmdLine);
	DBG_UNREFERENCED_PARAMETER(nCmdShow);

	#ifdef _DEBUG
	ID3D11Debug *debugInterface = nullptr;
	#endif
	
	// Force scope so we can guarantee the destructor is called before we try to use ReportLiveDeviceObjects
	{
		PBRDemo::PBRDemo app(hInstance);

		app.Initialize(L"Physically Based Rendering Demo", 1280, 720, false);

		#ifdef _DEBUG
		app.CreateDebugInterface(&debugInterface);
		#endif

		app.Run();

		app.Shutdown();
	}

	#ifdef _DEBUG
	debugInterface->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);

	ReleaseCOM(debugInterface);
	#endif

	return 0;
}
Esempio n. 3
0
void CleanupDevice()
{
	ShutdownWindows();
	if( g_pImmediateContext ) g_pImmediateContext->ClearState();

	if( g_pBackBuffer ) g_pBackBuffer->Release();
	if( g_pSwapChain ) g_pSwapChain->Release();
	if( g_pImmediateContext ) g_pImmediateContext->Release();
	if( g_pd3dDevice ) g_pd3dDevice->Release();

#ifdef _DEBUG 
	ID3D11Debug *debugDev;
	g_pd3dDevice->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&debugDev));
	debugDev->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);

#endif

}
void DirectXController::Shutdown( void )
{
	// Release the DX stuff
	ReleaseCOMobjMacro( renderTargetView );
	ReleaseCOMobjMacro( depthStencilView );
	ReleaseCOMobjMacro( swapChain );
	ReleaseCOMobjMacro( depthStencilBuffer );

	// Restore default device settings
	if( deviceContext.dx )
		deviceContext.dx->ClearState();

	// Release the context and finally the device
	ReleaseCOMobjMacro( deviceContext.dx );
	
#if defined(_DEBUG) || defined(DEBUG)
	ID3D11Debug* debugDev;
	device.dx->QueryInterface(__uuidof(ID3D11Debug), reinterpret_cast<void**>(&debugDev));
	debugDev->ReportLiveDeviceObjects( D3D11_RLDO_DETAIL );
#endif
	ReleaseCOMobjMacro( device.dx );

}
Esempio n. 5
0
void DirectxData::Release()
{
    selectedShader = NO_INDEX;
    fadeAmount = 0.0f;

    if (shadows)
    {
        shadows->Release();
    }

    for(auto& texture : textures)
    {
        texture->Release();
    }

    for(auto& mesh : meshes)
    {
        mesh->Release();
    }

    for(auto& mesh : terrain)
    {
        mesh->Release();
    }

    for(auto& water : waters)
    {
        water->Release();
    }

    for(auto& shader : shaders)
    {
        shader->Release();
    }

    for (auto& emitter : emitters)
    {
        emitter->Release();
    }

    quad.Release();
    sceneTarget.Release();
    blurTarget.Release();
    backBuffer.Release();
    preEffectsTarget.Release();

    for (unsigned int i = 0; i < drawStates.size(); ++i)
    {
        SafeRelease(&drawStates[i]);
    }

    for (unsigned int i = 0; i < samplers.size(); ++i)
    {
        SafeRelease(&samplers[i]);
    }

    SafeRelease(&noBlendState);
    SafeRelease(&alphaBlendState);
    SafeRelease(&alphaBlendMultiply);
    SafeRelease(&writeState);
    SafeRelease(&noWriteState);
    SafeRelease(&swapchain);
    SafeRelease(&context);
    SafeRelease(&device);

    if(debug)
    {
        debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
        debug->Release();
        debug = nullptr;

        std::string seperator(100, '=');
        OutputDebugString((seperator + "\n").c_str());
    }
}