Compare commits
No commits in common. "directx" and "main" have entirely different histories.
|
@ -1,86 +1,18 @@
|
||||||
#include <skunkworks.h>
|
#include <skunkworks.h>
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
void render() {
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
LRESULT wndproc(HWND hwnd, u32 msg, WPARAM wparam, LPARAM lparam);
|
|
||||||
|
|
||||||
wchar_t *sw_str_to_wstr(char *str) {
|
|
||||||
i32 size;
|
|
||||||
wchar_t *out;
|
|
||||||
|
|
||||||
size = MultiByteToWideChar(CP_UTF8, 0, str, -1, 0, 0);
|
|
||||||
out = malloc(size);
|
|
||||||
MultiByteToWideChar(CP_UTF8, 0, str, -1, out, size);
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
WNDCLASSEXW wndclass = {0};
|
struct sw_window *win;
|
||||||
HWND hwnd;
|
struct sw_renderer2d *ren;
|
||||||
|
|
||||||
wndclass.cbSize = sizeof(wndclass);
|
sw_init(argc, argv);
|
||||||
wndclass.style = 0;
|
|
||||||
wndclass.lpfnWndProc = wndproc;
|
|
||||||
wndclass.cbClsExtra = 0;
|
|
||||||
wndclass.cbWndExtra = 0;
|
|
||||||
wndclass.hInstance = 0;
|
|
||||||
wndclass.hIcon = 0;
|
|
||||||
wndclass.hCursor = 0;
|
|
||||||
wndclass.hbrBackground = 0;
|
|
||||||
wndclass.lpszMenuName = 0;
|
|
||||||
wndclass.lpszClassName = L"Skunkworks";
|
|
||||||
wndclass.hIconSm = 0;
|
|
||||||
|
|
||||||
RegisterClassExW(&wndclass);
|
win = sw_window_create(sw_vec2i(1280, 720), "example", 0);
|
||||||
|
ren = sw_renderer2d_create();
|
||||||
|
sw_window_add_renderer(win, ren->renderer, render);
|
||||||
|
sw_window_run(win);
|
||||||
|
|
||||||
hwnd = CreateWindowExW(
|
|
||||||
0,
|
|
||||||
L"Skunkworks",
|
|
||||||
L"Skunkworks test",
|
|
||||||
WS_POPUPWINDOW | WS_VISIBLE,
|
|
||||||
(1920 - 1280) / 2,
|
|
||||||
(1080 - 720) / 2,
|
|
||||||
1280,
|
|
||||||
720,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
ShowWindow(hwnd, SW_SHOW);
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
MSG msg;
|
|
||||||
|
|
||||||
while (PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)) {
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessageW(&msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LRESULT wndproc(HWND hwnd, u32 msg, WPARAM wparam, LPARAM lparam) {
|
|
||||||
switch (msg) {
|
|
||||||
case WM_CLOSE:
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
exit(0);
|
|
||||||
case WM_PAINT: {
|
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HDC hdc = BeginPaint(hwnd, &ps);
|
|
||||||
|
|
||||||
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW + 1));
|
|
||||||
|
|
||||||
EndPaint(hwnd, &ps);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue