First commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
build-mingw
|
||||||
|
.clangd
|
||||||
19
meson.build
Normal file
19
meson.build
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
project('scuffedcraft', 'c')
|
||||||
|
|
||||||
|
cargs = [
|
||||||
|
'-std=c99',
|
||||||
|
'-Og'
|
||||||
|
]
|
||||||
|
if host_machine.system() == 'windows'
|
||||||
|
cargs += [
|
||||||
|
'-DUNICODE',
|
||||||
|
'-D__UNICODE',
|
||||||
|
'-municode'
|
||||||
|
]
|
||||||
|
endif
|
||||||
|
|
||||||
|
executable(
|
||||||
|
'scuffedcraft',
|
||||||
|
'./src/main.c',
|
||||||
|
c_args: cargs
|
||||||
|
)
|
||||||
83
src/main.c
Normal file
83
src/main.c
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winuser.h>
|
||||||
|
|
||||||
|
// int _main() {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #ifdef __MINGW32__
|
||||||
|
|
||||||
|
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
|
switch (uMsg) {
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case WM_PAINT: {
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
HDC hdc = BeginPaint(hwnd, &ps);
|
||||||
|
|
||||||
|
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW + 1));
|
||||||
|
|
||||||
|
EndPaint(hwnd, &ps);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) {
|
||||||
|
// Register the window class
|
||||||
|
const wchar_t* CLASS_NAME = L"Sample Window Class";
|
||||||
|
|
||||||
|
WNDCLASS wc = { };
|
||||||
|
wc.lpfnWndProc = WindowProc;
|
||||||
|
wc.hInstance = hInstance;
|
||||||
|
wc.lpszClassName = CLASS_NAME;
|
||||||
|
|
||||||
|
RegisterClass(&wc);
|
||||||
|
|
||||||
|
// Create the window
|
||||||
|
HWND hwnd = CreateWindowEx(
|
||||||
|
0, // Optional window styles
|
||||||
|
CLASS_NAME, // Window class
|
||||||
|
L"Learn to Program Windows", // Window text
|
||||||
|
WS_OVERLAPPEDWINDOW, // Window style
|
||||||
|
|
||||||
|
// Size and position
|
||||||
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
|
|
||||||
|
NULL, // Parent window
|
||||||
|
NULL, // Menu
|
||||||
|
hInstance, // Instance handle
|
||||||
|
NULL // Additional application data
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hwnd == NULL) {
|
||||||
|
printf("ERROR: hwnd was NULL\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowWindow(hwnd, nCmdShow);
|
||||||
|
|
||||||
|
// Message loop
|
||||||
|
|
||||||
|
MSG msg = {};
|
||||||
|
while (GetMessage(&msg, NULL, 0, 0) > 0) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #else
|
||||||
|
//
|
||||||
|
// int main() {
|
||||||
|
// _main();
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// #endif
|
||||||
9
x86_64-w64-mingw32-clang.txt
Normal file
9
x86_64-w64-mingw32-clang.txt
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[binaries]
|
||||||
|
c = 'x86_64-w64-mingw32-clang'
|
||||||
|
exe_wrapper = 'wine'
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
system = 'windows'
|
||||||
|
cpu_family = 'x86_64'
|
||||||
|
cpu = 'x86_64'
|
||||||
|
endian = 'little'
|
||||||
Reference in New Issue
Block a user