window_interface.odin 1.3 KB

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