#include "Application.h" #include #include #include LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int nCmdShow) { AllocConsole(); freopen("CONOUT$", "w", stdout); printf("Starting UI application...\n"); WNDCLASSEXW wc = {}; wc.cbSize = sizeof(wc); wc.style = CS_CLASSDC; wc.lpfnWndProc = WndProc; wc.hInstance = GetModuleHandle(nullptr); wc.lpszClassName = L"XCVolumeRendererUI2"; if (!RegisterClassExW(&wc)) { printf("Failed to register window class, error: %lu\n", GetLastError()); return 1; } printf("Window class registered.\n"); HWND hwnd = CreateWindowExW( 0, wc.lpszClassName, L"XCVolumeRenderer - Unity Style Editor", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 720, nullptr, nullptr, wc.hInstance, nullptr ); if (!hwnd) { printf("Failed to create window, error: %lu\n", GetLastError()); return 1; } printf("Window created.\n"); ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); printf("Window shown.\n"); printf("Initializing application...\n"); if (!XCEngine::Editor::Application::Get().Initialize(hwnd)) { printf("Failed to initialize application!\n"); UnregisterClassW(wc.lpszClassName, wc.hInstance); system("pause"); return 1; } printf("Application initialized successfully.\n"); MSG msg = {}; int frameCount = 0; while (msg.message != WM_QUIT) { if (PeekMessageW(&msg, nullptr, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } else { XCEngine::Editor::Application::Get().Render(); frameCount++; if (frameCount % 100 == 0) { printf("Frame %d\n", frameCount); } } } printf("Shutting down...\n"); XCEngine::Editor::Application::Get().Shutdown(); UnregisterClassW(wc.lpszClassName, wc.hInstance); printf("Press any key to exit...\n"); system("pause"); return 0; } extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) return true; switch (msg) { case WM_SIZE: if (wParam != SIZE_MINIMIZED) { XCEngine::Editor::Application::Get().OnResize((int)LOWORD(lParam), (int)HIWORD(lParam)); } return 0; case WM_SYSCOMMAND: if ((wParam & 0xfff0) == SC_KEYMENU) return 0; break; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProcW(hWnd, msg, wParam, lParam); }