DX11Starter/Game.cpp
// --------------------------------------------------------
// Destructor - Clean up anything our game has created:
//  - Release all DirectX objects created here
//  - Delete any objects to prevent memory leaks
// --------------------------------------------------------
Clean up anything our game has created:
Release all DirectX objects created here
Delete any objects to prevent memory leaks
Clean up anything our game has created : Release all DirectX objects created here Delete any objects to prevent memory leaks
Game::~Game()
{
	std::vector<Entity*>::iterator it;
	for (it = entities.begin(); it < entities.end(); it++) {
		delete *it;
	}
	if (meshes != nullptr) {
		for (int i = 0; i < meshCount; i++) {
			if (meshes[i] != nullptr) {
				delete meshes[i];
			}
		}
		delete meshes;
	}
	delete baseMaterial;
	delete crate;
	delete blue;
	delete lights;
	delete vertexShader;
	delete pixelShader;
	delete camera;
	sampler->Release();
	defaultSrv->Release();
	crateSrv->Release();
	defaultTexture->Release();
}
Game :: ~ Game ( ) { std :: vector < Entity * > :: iterator it ; for ( it = entities . begin ( ) ; it < entities . end ( ) ; it ++ ) { delete * it ; } if ( meshes != nullptr ) { for ( int i = 0 ; i < meshCount ; i ++ ) { if ( meshes [ i ] != nullptr ) { delete meshes [ i ] ; } } delete meshes ; } delete baseMaterial ; delete crate ; delete blue ; delete lights ; delete vertexShader ; delete pixelShader ; delete camera ; sampler -> Release ( ) ; defaultSrv -> Release ( ) ; crateSrv -> Release ( ) ; defaultTexture -> Release ( ) ; }
Destructor - Clean up anything our game has created:
 Release all DirectX objects created here
 Delete any objects to prevent memory leaks
Destructor - Clean up anything our game has created : Release all DirectX objects created here Delete any objects to prevent memory leaks
// Delete our simple shader objects, which // will clean up their own internal DirectX stuff