Exemplo n.º 1
0
	void Render()
	{

		if (!m_renderTarget)
		{
			auto d3dDevice = CreateD3D11Device();
			m_renderTarget = CreateRenderTarget(m_d2dFactory, d3dDevice);
			m_swapChain = CreateSwapChainForHwnd(d3dDevice, __super::m_hWnd);

			CreateDeviceSwapChainBitmap(m_swapChain, m_renderTarget);

			static_cast<T *>(this)->CreateDeviceResources();
			static_cast<T *>(this)->CreateDeviceSizeResources();
		}

		m_renderTarget->BeginDraw();
		// NOTE: no fallback is provided in this base class so all derived classes must implement this
		static_cast<T *>(this)->Draw();
		m_renderTarget->EndDraw();

		auto const hr = m_swapChain->Present(1, 0);
		if (S_OK != hr && DXGI_STATUS_OCCLUDED != hr)
		{
			ReleaseDevices();
		}
	}
Exemplo n.º 2
0
	void ResizeSwapChainBitmap()
	{
		ASSERT(m_renderTarget);
		ASSERT(m_swapChain);

		m_renderTarget->SetTarget(nullptr);

		if (S_OK == m_swapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0))
		{
			CreateDeviceSwapChainBitmap(m_swapChain, m_renderTarget);

			// here we need to recreate window size dependent resources
			static_cast<T *>(this)->CreateDeviceSizeResources();
		}
		else
		{
			ReleaseDevices();
		}

	}
		InputManager::~InputManager()
		{
		ReleaseDevices();
		myInitialized = false;
		}