text: #include "pch.h"
  #include "HelloWorldGame.h"
  
  using namespace std;
  using namespace DirectX;
  using namespace Library;
  
  namespace HelloWorld
  {
  	const XMVECTORF32 HelloWorldGame::BackgroundColor = Colors::CornflowerBlue;
  
  	HelloWorldGame::HelloWorldGame(function<void*()> getWindowCallback, function<void(SIZE&)> getRenderTargetSizeCallback) :
  		Game(getWindowCallback, getRenderTargetSizeCallback)
  	{
  	}
  
  	void HelloWorldGame::Initialize()
  	{
  		mKeyboard = make_shared<KeyboardComponent>(*this);
  		mComponents.push_back(mKeyboard);
  		mServices.AddService(KeyboardComponent::TypeIdClass(), mKeyboard.get());
  
  		Game::Initialize();
  	}
  
  	void HelloWorldGame::Update(const GameTime &gameTime)
  	{
  		if (mKeyboard->WasKeyPressedThisFrame(Keys::Escape))
  		{
  			Exit();
  		}
  
  		Game::Update(gameTime);
  	}
  
  	void HelloWorldGame::Draw(const GameTime &gameTime)
  	{
  		mDirect3DDeviceContext->ClearRenderTargetView(mRenderTargetView.Get(), reinterpret_cast<const float*>(&BackgroundColor));
  		mDirect3DDeviceContext->ClearDepthStencilView(mDepthStencilView.Get(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
  
  		Game::Draw(gameTime);
  
  		HRESULT hr = mSwapChain->Present(1, 0);
  
  		// If the device was removed either by a disconnection or a driver upgrade, we must recreate all device resources.
  		if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET)
  		{
  			HandleDeviceLost();
  		}
  		else
  		{
  			ThrowIfFailed(hr, "IDXGISwapChain::Present() failed.");
  		}
  	}
  
  	void HelloWorldGame::Exit()
  	{
  		PostQuitMessage(0);
  	}
  }