Exemplo n.º 1
0
U32 Application::Run()
{
	m_timer.Reset();
	
	auto hwnd = m_pWindow->GetHandle();
	auto bWindowActive = true;
	while (!m_pWindow->ShouldClose())
	{
		auto activeWindow = GetForegroundWindow();
		if (activeWindow != hwnd)
		{
			g_inputManager.EnableCursor();
			g_inputManager.SetRMBUp();
			g_inputManager.SetLMBUp();
			m_pWindow->Unclip();
			bWindowActive = false;
		}
		else
		{
			if (!bWindowActive)
			{
				g_inputManager.EnableCursor();
				bWindowActive = true;
			}
		}

		g_inputManager.Reset();

		m_pWindow->RunMessageLoop();
		
		m_timer.Update();
		g_eventManager.PostEvent(CreateTickEvent(m_timer.GetElapsed()));
		g_eventManager.DispatchEvents();
		UpdateScene(m_timer.GetElapsed());

		CopyRenderData();
		m_pRenderer->Render();
	}

	return 0;
}