Karl Zylinski 6 місяців тому
батько
коміт
d0a3519f0c
3 змінених файлів з 17 додано та 1 видалено
  1. 3 1
      karl2d.odin
  2. 1 0
      window_interface.odin
  3. 13 0
      window_win32.odin

+ 3 - 1
karl2d.odin

@@ -159,7 +159,9 @@ set_window_position :: proc(x: int, y: int) {
 }
 
 set_window_size :: proc(width: int, height: int) {
-	panic("Not implemented")
+	// TODO not sure if we should resize swapchain here. On windows the WM_SIZE event fires and
+	// it all works out. But perhaps not on all platforms?
+	win.set_size(width, height)
 }
 
 // Flushes the current batch. This sends off everything to the GPU that has been queued in the

+ 1 - 0
window_interface.odin

@@ -9,6 +9,7 @@ Window_Interface :: struct {
 	get_events: proc() -> []Window_Event,
 	clear_events: proc(),
 	set_position: proc(x: int, y: int),
+	set_size: proc(w, h: int),
 
 	set_internal_state: proc(state: rawptr),
 }

+ 13 - 0
window_win32.odin

@@ -12,6 +12,7 @@ WINDOW_INTERFACE_WIN32 :: Window_Interface {
 	get_events = win32_get_events,
 	clear_events = win32_clear_events,
 	set_position = win32_set_position,
+	set_size = win32_set_size,
 	set_internal_state = win32_set_internal_state,
 }
 
@@ -100,6 +101,18 @@ win32_set_position :: proc(x: int, y: int) {
 	)
 }
 
+win32_set_size :: proc(w, h: int) {
+	win32.SetWindowPos(
+		s.hwnd,
+		{},
+		0,
+		0,
+		i32(w),
+		i32(h),
+		win32.SWP_NOACTIVATE | win32.SWP_NOZORDER | win32.SWP_NOMOVE,
+	)
+}
+
 win32_set_internal_state :: proc(state: rawptr) {
 	assert(state != nil)
 	s = (^Win32_State)(state)