aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index d901e66..a55a439 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -27,9 +27,59 @@ window::window(uint32_t width, uint32_t height)
xcb_map_window(connection, win);
xcb_flush(connection);
+
+ isOpen = true;
}
#elif defined(WINDOWS)
+LRESULT CALLBACK window::window_procedure(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam) {
+ window* win = nullptr;
+
+ if (umsg == WM_CREATE) {
+ LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lparam;
+ win = (window*)lpcs->lpCreateParams;
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)win);
+ } else {
+ win = (window*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ }
+
+ return DefWindowProc(hwnd, umsg, wparam, lparam);
+}
+
window::window(uint32_t width, uint32_t height)
:width(width), height(height) {
+ auto process_handle = GetModuleHandle(NULL);
+
+ WNDCLASS window_class = {};
+ window_class.style = 0;
+ window_class.lpfnWndProc = &window::window_procedure;
+ window_class.cbClsExtra = 0;
+ window_class.cbWndExtra = 0;
+ window_class.hInstance = process_handle;
+ window_class.hIcon = NULL;
+ window_class.hCursor = NULL;
+ window_class.hbrBackground = NULL;
+ window_class.lpszMenuName = NULL;
+ window_class.lpszClassName = "default-window";
+
+ RegisterClass(&window_class);
+
+ win_handle = CreateWindow(
+ "default-window",
+ "path-tracer",
+ WS_OVERLAPPEDWINDOW,
+ 10,
+ 10,
+ width,
+ height,
+ NULL,
+ NULL,
+ process_handle,
+ this
+ );
+
+ ShowWindow(win_handle, SW_SHOW);
+
+ isOpen = true;
}
#endif