window_interface.odin 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package karl2d
  2. import "base:runtime"
  3. Window_Interface :: struct #all_or_none {
  4. state_size: proc() -> int,
  5. init: proc(
  6. window_state: rawptr,
  7. window_width: int,
  8. window_height: int,
  9. window_title: string,
  10. init_options: Init_Options,
  11. allocator: runtime.Allocator,
  12. ),
  13. shutdown: proc(),
  14. window_handle: proc() -> Window_Handle,
  15. process_events: proc(),
  16. get_events: proc() -> []Window_Event,
  17. clear_events: proc(),
  18. set_position: proc(x: int, y: int),
  19. set_size: proc(w, h: int),
  20. get_width: proc() -> int,
  21. get_height: proc() -> int,
  22. get_window_scale: proc() -> f32,
  23. set_window_mode: proc(window_mode: Window_Mode),
  24. is_gamepad_active: proc(gamepad: int) -> bool,
  25. get_gamepad_axis: proc(gamepad: int, axis: Gamepad_Axis) -> f32,
  26. set_gamepad_vibration: proc(gamepad: int, left: f32, right: f32),
  27. set_internal_state: proc(state: rawptr),
  28. }
  29. Window_Handle :: distinct uintptr
  30. Window_Event :: union {
  31. Window_Event_Close_Wanted,
  32. Window_Event_Key_Went_Down,
  33. Window_Event_Key_Went_Up,
  34. Window_Event_Mouse_Move,
  35. Window_Event_Mouse_Wheel,
  36. Window_Event_Resize,
  37. Window_Event_Mouse_Button_Went_Down,
  38. Window_Event_Mouse_Button_Went_Up,
  39. Window_Event_Gamepad_Button_Went_Down,
  40. Window_Event_Gamepad_Button_Went_Up,
  41. }
  42. Window_Event_Key_Went_Down :: struct {
  43. key: Keyboard_Key,
  44. }
  45. Window_Event_Key_Went_Up :: struct {
  46. key: Keyboard_Key,
  47. }
  48. Window_Event_Mouse_Button_Went_Down :: struct {
  49. button: Mouse_Button,
  50. }
  51. Window_Event_Mouse_Button_Went_Up :: struct {
  52. button: Mouse_Button,
  53. }
  54. Window_Event_Gamepad_Button_Went_Down :: struct {
  55. gamepad: int,
  56. button: Gamepad_Button,
  57. }
  58. Window_Event_Gamepad_Button_Went_Up :: struct {
  59. gamepad: int,
  60. button: Gamepad_Button,
  61. }
  62. Window_Event_Close_Wanted :: struct {}
  63. Window_Event_Mouse_Move :: struct {
  64. position: Vec2,
  65. }
  66. Window_Event_Mouse_Wheel :: struct {
  67. delta: f32,
  68. }
  69. Window_Event_Resize :: struct {
  70. width, height: int,
  71. }