windows open now
This commit is contained in:
1 parent
4ec42f4bee
commit
f96b2e99cf
6 files changed
+72
-2
No files matched your search
@@ -13,6 +13,8 @@
|
|||||||
#include "render/render_inc.c"
|
#include "render/render_inc.c"
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
global WM_Window hello;
|
||||||
|
|
||||||
internal bool32 frame()
|
internal bool32 frame()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -22,8 +24,18 @@ internal bool32 frame()
|
|||||||
bool32 wait = 0;
|
bool32 wait = 0;
|
||||||
events = wm_get_events(scratch.arena, wait);
|
events = wm_get_events(scratch.arena, wait);
|
||||||
|
|
||||||
|
if (hello.handle[0] == 0)
|
||||||
|
{
|
||||||
|
hello = wm_window_open(rect2fp(50.f, 50.f, 1280.f, 720.f), WM_WindowFlag_UseDefaultPosition, str8_literal("Hello"));
|
||||||
|
wm_window_first_paint(hello);
|
||||||
|
}
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
sleep_ms(16);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,10 +43,9 @@ internal void entry_point()
|
|||||||
{
|
{
|
||||||
wm_init();
|
wm_init();
|
||||||
|
|
||||||
wm_window_open(rect2fp(50.f, 50.f, 1280.f, 720.f), 0, str8_literal("Hello"));
|
|
||||||
|
|
||||||
for (bool32 quit = 0; !quit;)
|
for (bool32 quit = 0; !quit;)
|
||||||
{
|
{
|
||||||
quit = update();
|
quit = update();
|
||||||
}
|
}
|
||||||
|
wm_window_close(hello);
|
||||||
}
|
}
|
||||||
@@ -261,3 +261,4 @@ internal int32 safe_cast_int32(int64 val);
|
|||||||
// Time functions
|
// Time functions
|
||||||
|
|
||||||
internal uint64 now_time_us();
|
internal uint64 now_time_us();
|
||||||
|
internal void sleep_ms(uint32 ms);
|
||||||
@@ -20,6 +20,11 @@ internal uint64 now_time_us()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void sleep_ms(uint32 ms)
|
||||||
|
{
|
||||||
|
Sleep(ms);
|
||||||
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// System
|
// System
|
||||||
|
|
||||||
|
|||||||
@@ -229,6 +229,32 @@ internal LRESULT w32_wm_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
result = 0;
|
result = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_NCACTIVATE:
|
||||||
|
{
|
||||||
|
if (!w32_wm_new_window_custom_border && (window == 0 || window->custom_border == 0))
|
||||||
|
{
|
||||||
|
result = DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = DefWindowProcW(hwnd, uMsg, wParam, -1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_NCCALCSIZE:
|
||||||
|
{
|
||||||
|
if (w32_wm_new_window_custom_border || (window && window->custom_border))
|
||||||
|
{
|
||||||
|
float32 dpi = w32_GetDpiForWindow_func ? (float32)w32_GetDpiForWindow_func(hwnd) : 96.f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -459,6 +485,29 @@ internal WM_Window wm_window_open(Rect2f rect, WM_WindowFlags flags, String8 tit
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void wm_window_close(WM_Window handle)
|
||||||
|
{
|
||||||
|
W32_WM_Window* window = w32_wm_window_from_handle(handle);
|
||||||
|
if (window != 0)
|
||||||
|
{
|
||||||
|
w32_wm_window_release(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void wm_window_first_paint(WM_Window window_handle)
|
||||||
|
{
|
||||||
|
W32_WM_Window* window = w32_wm_window_from_handle(window_handle);
|
||||||
|
if (window)
|
||||||
|
{
|
||||||
|
window->first_paint_done = 1;
|
||||||
|
ShowWindow(window->hwnd, SW_SHOW);
|
||||||
|
if (window->maximized)
|
||||||
|
{
|
||||||
|
ShowWindow(window->hwnd, SW_MAXIMIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal Rect2f wm_client_rect_from_window(WM_Window handle)
|
internal Rect2f wm_client_rect_from_window(WM_Window handle)
|
||||||
{
|
{
|
||||||
Rect2f result = { 0 };
|
Rect2f result = { 0 };
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ struct W32_WM_Window
|
|||||||
HDC hdc;
|
HDC hdc;
|
||||||
WINDOWPLACEMENT last_window_placement;
|
WINDOWPLACEMENT last_window_placement;
|
||||||
float32 dpi;
|
float32 dpi;
|
||||||
|
bool32 first_paint_done;
|
||||||
|
bool32 maximized;
|
||||||
bool32 custom_border;
|
bool32 custom_border;
|
||||||
float32 custom_border_title_thickness;
|
float32 custom_border_title_thickness;
|
||||||
float32 custom_border_edge_thickness;
|
float32 custom_border_edge_thickness;
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ internal void wm_init();
|
|||||||
// Windows
|
// Windows
|
||||||
|
|
||||||
internal WM_Window wm_widow_open(Rect2f rect, WM_WindowFlags flags, String8 title);
|
internal WM_Window wm_widow_open(Rect2f rect, WM_WindowFlags flags, String8 title);
|
||||||
|
internal void wm_window_close(WM_Window handle);
|
||||||
|
internal void wm_window_first_paint(WM_Window window_handle);
|
||||||
internal Rect2f wm_client_rect_from_window(WM_Window window);
|
internal Rect2f wm_client_rect_from_window(WM_Window window);
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|||||||
Reference in new issue
Block a user