Files
XCEngine/new_editor/app/Bootstrap/ApplicationRunLoop.cpp

46 lines
1.1 KiB
C++
Raw Normal View History

#include "Bootstrap/Application.h"
#include "Platform/Win32/EditorWindowManager.h"
namespace XCEngine::UI::Editor {
int Application::Run(HINSTANCE hInstance, int nCmdShow) {
if (!Initialize(hInstance, nCmdShow)) {
Shutdown();
return 1;
}
constexpr int kMaxMessagesPerTick = 64;
MSG message = {};
while (true) {
int processedMessageCount = 0;
while (processedMessageCount < kMaxMessagesPerTick &&
PeekMessageW(&message, nullptr, 0U, 0U, PM_REMOVE)) {
if (message.message == WM_QUIT) {
Shutdown();
return static_cast<int>(message.wParam);
}
TranslateMessage(&message);
DispatchMessageW(&message);
++processedMessageCount;
}
if (m_windowManager != nullptr) {
m_windowManager->DestroyClosedWindows();
if (!m_windowManager->HasWindows()) {
break;
}
m_windowManager->RenderAllWindows();
} else {
break;
}
}
Shutdown();
return 0;
}
} // namespace XCEngine::UI::Editor