fixed calling convention
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#ifndef PLATFORM_INCLUDED
|
#ifndef PLATFORM_INCLUDED
|
||||||
#define PLATFORM_INCLUDED
|
#define PLATFORM_INCLUDED
|
||||||
|
|
||||||
extern int plat_main(void);
|
extern int plat_main(int argc, char **argv);
|
||||||
|
|
||||||
#endif // platform.h
|
#endif // platform.h
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
#include "../include/platform.h"
|
#include "../include/platform.h"
|
||||||
|
|
||||||
int plat_main(void) {
|
int plat_main(int argc, char **argv) {
|
||||||
|
(void) argc;
|
||||||
|
(void) argv;
|
||||||
Display *display = XOpenDisplay(NULL);
|
Display *display = XOpenDisplay(NULL);
|
||||||
if (!display) {
|
if (!display) {
|
||||||
fprintf(stderr, "Cannot open display\n");
|
fprintf(stderr, "Cannot open display\n");
|
||||||
|
|||||||
@@ -14,44 +14,50 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI plat_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
int plat_main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
// 1. Register the window class
|
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||||
WNDCLASS wc = {};
|
const char CLASS_NAME[] = "MyWindowClass";
|
||||||
|
|
||||||
|
// Step 1: Register the window class
|
||||||
|
WNDCLASS wc = {0};
|
||||||
wc.lpfnWndProc = WndProc;
|
wc.lpfnWndProc = WndProc;
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.lpszClassName = "MyWindowClass";
|
wc.lpszClassName = CLASS_NAME;
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
|
||||||
|
|
||||||
RegisterClass(&wc);
|
if (!RegisterClass(&wc)) {
|
||||||
|
MessageBox(NULL, "Failed to register window class!", "Error", MB_OK | MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Create the window
|
// Step 2: Create the window
|
||||||
HWND hwnd = CreateWindowEx(
|
HWND hwnd = CreateWindowEx(
|
||||||
0, // Extended style
|
0, // Optional window styles
|
||||||
"MyWindowClass", // Class name
|
CLASS_NAME, // Window class
|
||||||
"Hello, Win32!", // Window title
|
"My Win32 Window", // Window title
|
||||||
WS_OVERLAPPEDWINDOW, // Style (title bar, border, min/max/close buttons)
|
WS_OVERLAPPEDWINDOW, // Window style
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, // x, y, width, height
|
CW_USEDEFAULT, CW_USEDEFAULT, 500, 400, // x, y, width, height
|
||||||
NULL, // Parent window
|
NULL, // Parent window
|
||||||
NULL, // Menu
|
NULL, // Menu
|
||||||
hInstance,
|
hInstance, // Instance handle
|
||||||
NULL
|
NULL // Additional application data
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!hwnd) return -1;
|
if (!hwnd) {
|
||||||
|
MessageBox(NULL, "Failed to create window!", "Error", MB_OK | MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Show the window
|
ShowWindow(hwnd, SW_SHOW);
|
||||||
ShowWindow(hwnd, nCmdShow);
|
|
||||||
UpdateWindow(hwnd);
|
UpdateWindow(hwnd);
|
||||||
|
|
||||||
// 4. Message loop
|
// Step 3: Message loop
|
||||||
MSG msg = {};
|
MSG msg;
|
||||||
while (GetMessage(&msg, NULL, 0, 0))
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)msg.wParam;
|
return (int)msg.wParam;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#define DEBUG
|
#define DEBUG
|
||||||
#include "../include/platform.h"
|
#include "../include/platform.h"
|
||||||
int main(void){
|
int main(int argc, char **argv){
|
||||||
|
|
||||||
return plat_main();
|
return plat_main(argc,argv);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user