Window struct access fix

This commit is contained in:
2026-05-11 13:03:22 -05:00
parent 76f771f148
commit 128b342c89
3 changed files with 6 additions and 8 deletions

View File

@@ -40,7 +40,6 @@ CI2_Window* platform_create_window(const ci2_sys_char* title, int width, int hei
static ci2_bool class_registered = false;
static ci2_sys_char *ci2_window_class = L"Win32 CI2 Window Class"
if (!class_registered) {
WNDCLASS wc = {0};
wc.lpfnWndProc = window_proc;
@@ -73,6 +72,9 @@ CI2_Window* platform_create_window(const ci2_sys_char* title, int width, int hei
window->hwnd = hwnd;
window->should_close = false;
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)window);
ShowWindow(window->hwnd, nShowCmd);
UpdateWindow(window->hwnd);
return window;
}

View File

@@ -26,8 +26,9 @@
#ifdef CI2_WINDOWS
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
(void)hPrevInstance; // unused
(void)lpCmdLine; // unused
(void)hInstance;
(void)hPrevInstance;
(void)lpCmdLine;
if (!ci2_init()) {
MessageBoxA(NULL, "ci2_init failed", "Error", MB_OK | MB_ICONERROR);
@@ -41,11 +42,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
return EXIT_FAILURE;
}
// 3) ShowWindow: CreateWindowEx in your ci2 already passed WS_VISIBLE, but call ShowWindow
// to respect the nShowCmd semantics (e.g. SW_MINIMIZE). This is optional if the ci2 layer already shows.
ShowWindow(window->hwnd, nShowCmd);
UpdateWindow(window->hwnd);
// 4) Main loop: run until ci2_poll_events reports the window should close.
// This loop is friendly to rendering or other per-frame work.

Binary file not shown.