Parcourir la source

Properly restore internal state on set_internal_state

Karl Zylinski il y a 6 mois
Parent
commit
4265b19eb0
3 fichiers modifiés avec 11 ajouts et 0 suppressions
  1. 3 0
      karl2d.odin
  2. 2 0
      window_interface.odin
  3. 6 0
      window_win32.odin

+ 3 - 0
karl2d.odin

@@ -153,7 +153,10 @@ draw_current_batch :: proc() {
 // reloading the library (for example, when doing code hot reload).
 set_internal_state :: proc(state: ^State) {
 	s = state
+	rb = s.rb
+	win = s.win
 	rb.set_internal_state(s.rb_state)
+	win.set_internal_state(s.window_state)
 }
 
 get_screen_width :: proc() -> int {

+ 2 - 0
window_interface.odin

@@ -9,6 +9,8 @@ Window_Interface :: struct {
 	get_events: proc() -> []Window_Event,
 	clear_events: proc(),
 	set_position: proc(x: int, y: int),
+
+	set_internal_state: proc(state: rawptr),
 }
 
 Window_Handle :: distinct uintptr

+ 6 - 0
window_win32.odin

@@ -16,6 +16,7 @@ WINDOW_INTERFACE_WIN32 :: Window_Interface {
 	get_events = win32_get_events,
 	clear_events = win32_clear_events,
 	set_position = win32_set_position,
+	set_internal_state = win32_set_internal_state,
 }
 
 Win32_State :: struct {
@@ -91,6 +92,11 @@ win32_set_position :: proc(x: int, y: int) {
 	)
 }
 
+win32_set_internal_state :: proc(state: rawptr) {
+	assert(state != nil)
+	s = (^Win32_State)(state)
+}
+
 win32_window_handle :: proc() -> Window_Handle {
 	return Window_Handle(s.hwnd)
 }