window_interface.odin 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package karl2d
  2. Window_Interface :: struct {
  3. state_size: proc() -> int,
  4. init: proc(window_state: rawptr, window_width: int, window_height: int, window_title: string, allocator := context.allocator),
  5. shutdown: proc(),
  6. window_handle: proc() -> Window_Handle,
  7. process_events: proc(),
  8. get_events: proc() -> []Window_Event,
  9. clear_events: proc(),
  10. set_position: proc(x: int, y: int),
  11. set_size: proc(w, h: int),
  12. set_internal_state: proc(state: rawptr),
  13. }
  14. Window_Handle :: distinct uintptr
  15. Window_Event :: union {
  16. Window_Event_Close_Wanted,
  17. Window_Event_Key_Went_Down,
  18. Window_Event_Key_Went_Up,
  19. Window_Event_Mouse_Move,
  20. Window_Event_Mouse_Wheel,
  21. Window_Event_Resize,
  22. Window_Event_Mouse_Button_Went_Down,
  23. Window_Event_Mouse_Button_Went_Up,
  24. }
  25. Window_Event_Key_Went_Down :: struct {
  26. key: Keyboard_Key,
  27. }
  28. Window_Event_Key_Went_Up :: struct {
  29. key: Keyboard_Key,
  30. }
  31. Window_Event_Mouse_Button_Went_Down :: struct {
  32. button: Mouse_Button,
  33. }
  34. Window_Event_Mouse_Button_Went_Up :: struct {
  35. button: Mouse_Button,
  36. }
  37. Window_Event_Close_Wanted :: struct {}
  38. Window_Event_Mouse_Move :: struct {
  39. position: Vec2,
  40. }
  41. Window_Event_Mouse_Wheel :: struct {
  42. delta: f32,
  43. }
  44. Window_Event_Resize :: struct {
  45. width, height: int,
  46. }