window_interface.odin 1.7 KB

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