window_interface.odin 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. get_width: proc() -> int,
  15. get_height: proc() -> int,
  16. get_window_scale: proc() -> f32,
  17. set_flags: proc(flags: Window_Flags),
  18. is_gamepad_active: proc(gamepad: int) -> bool,
  19. get_gamepad_axis: proc(gamepad: int, axis: Gamepad_Axis) -> f32,
  20. set_gamepad_vibration: proc(gamepad: int, left: f32, right: f32),
  21. set_internal_state: proc(state: rawptr),
  22. }
  23. Window_Handle :: distinct uintptr
  24. Window_Event :: union {
  25. Window_Event_Close_Wanted,
  26. Window_Event_Key_Went_Down,
  27. Window_Event_Key_Went_Up,
  28. Window_Event_Mouse_Move,
  29. Window_Event_Mouse_Wheel,
  30. Window_Event_Resize,
  31. Window_Event_Mouse_Button_Went_Down,
  32. Window_Event_Mouse_Button_Went_Up,
  33. Window_Event_Gamepad_Button_Went_Down,
  34. Window_Event_Gamepad_Button_Went_Up,
  35. }
  36. Window_Event_Key_Went_Down :: struct {
  37. key: Keyboard_Key,
  38. }
  39. Window_Event_Key_Went_Up :: struct {
  40. key: Keyboard_Key,
  41. }
  42. Window_Event_Mouse_Button_Went_Down :: struct {
  43. button: Mouse_Button,
  44. }
  45. Window_Event_Mouse_Button_Went_Up :: struct {
  46. button: Mouse_Button,
  47. }
  48. Window_Event_Gamepad_Button_Went_Down :: struct {
  49. gamepad: int,
  50. button: Gamepad_Button,
  51. }
  52. Window_Event_Gamepad_Button_Went_Up :: struct {
  53. gamepad: int,
  54. button: Gamepad_Button,
  55. }
  56. Window_Event_Close_Wanted :: struct {}
  57. Window_Event_Mouse_Move :: struct {
  58. position: Vec2,
  59. }
  60. Window_Event_Mouse_Wheel :: struct {
  61. delta: f32,
  62. }
  63. Window_Event_Resize :: struct {
  64. width, height: int,
  65. }