2026-03-20 17:08:06 +08:00
|
|
|
#include "Application.h"
|
|
|
|
|
#include <imgui.h>
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
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");
|
2026-03-24 20:02:38 +08:00
|
|
|
if (!XCEngine::Editor::Application::Get().Initialize(hwnd)) {
|
2026-03-20 17:08:06 +08:00
|
|
|
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 {
|
2026-03-24 20:02:38 +08:00
|
|
|
XCEngine::Editor::Application::Get().Render();
|
2026-03-20 17:08:06 +08:00
|
|
|
frameCount++;
|
|
|
|
|
if (frameCount % 100 == 0) {
|
|
|
|
|
printf("Frame %d\n", frameCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("Shutting down...\n");
|
2026-03-24 20:02:38 +08:00
|
|
|
XCEngine::Editor::Application::Get().Shutdown();
|
2026-03-20 17:08:06 +08:00
|
|
|
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) {
|
2026-03-24 20:02:38 +08:00
|
|
|
XCEngine::Editor::Application::Get().OnResize((int)LOWORD(lParam), (int)HIWORD(lParam));
|
2026-03-20 17:08:06 +08:00
|
|
|
}
|
|
|
|
|
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);
|
2026-03-25 01:23:08 +08:00
|
|
|
}
|