window_interface.odin 1.8 KB

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