sdl_system.odin 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package sdl2
  2. import "core:c"
  3. when ODIN_OS == "windows" { foreign import lib "SDL2.lib" }
  4. when ODIN_OS == "linux" { foreign import lib "system:SDL2" }
  5. when ODIN_OS == "darwin" { foreign import lib "system:SDL2" }
  6. when ODIN_OS == "freebsd" { foreign import lib "system:SDL2" }
  7. // General
  8. @(default_calling_convention="c", link_prefix="SDL_")
  9. foreign lib {
  10. IsTablet :: proc() -> bool ---
  11. /* Functions used by iOS application delegates to notify SDL about state changes */
  12. OnApplicationWillTerminate :: proc() ---
  13. OnApplicationDidReceiveMemoryWarning :: proc() ---
  14. OnApplicationWillResignActive :: proc() ---
  15. OnApplicationDidEnterBackground :: proc() ---
  16. OnApplicationWillEnterForeground :: proc() ---
  17. OnApplicationDidBecomeActive :: proc() ---
  18. // iPhoneOS
  19. OnApplicationDidChangeStatusBarOrientation :: proc() ---
  20. }
  21. // Windows & WinRT
  22. WindowsMessageHook :: proc "c" (userdata: rawptr, hWnd: rawptr, message: c.uint, wParam: u64, lParam: i64)
  23. IDirect3DDevice9 :: struct {}
  24. ID3D11Device :: struct {}
  25. @(default_calling_convention="c", link_prefix="SDL_")
  26. foreign lib {
  27. SetWindowsMessageHook :: proc(callback: WindowsMessageHook, userdata: rawptr) ---
  28. Direct3D9GetAdapterIndex :: proc(displayIndex: c.int) -> c.int ---
  29. RenderGetD3D9Device :: proc(renderer: ^Renderer) -> ^IDirect3DDevice9 ---
  30. RenderGetD3D11Device :: proc(renderer: ^Renderer) -> ^ID3D11Device ---
  31. DXGIGetOutputInfo :: proc(displayIndex: c.int, adapterIndex: ^c.int, outputIndex: ^c.int) -> bool ---
  32. }
  33. WinRT_Path :: enum c.int {
  34. /** \brief The installed app's root directory.
  35. Files here are likely to be read-only. */
  36. INSTALLED_LOCATION,
  37. /** \brief The app's local data store. Files may be written here */
  38. LOCAL_FOLDER,
  39. /** \brief The app's roaming data store. Unsupported on Windows Phone.
  40. Files written here may be copied to other machines via a network
  41. connection.
  42. */
  43. ROAMING_FOLDER,
  44. /** \brief The app's temporary data store. Unsupported on Windows Phone.
  45. Files written here may be deleted at any time. */
  46. TEMP_FOLDER,
  47. }
  48. WinRT_DeviceFamily :: enum {
  49. /** \brief Unknown family */
  50. UNKNOWN,
  51. /** \brief Desktop family*/
  52. DESKTOP,
  53. /** \brief Mobile family (for example smartphone) */
  54. MOBILE,
  55. /** \brief XBox family */
  56. XBOX,
  57. }
  58. @(default_calling_convention="c", link_prefix="SDL_")
  59. foreign lib {
  60. WinRTGetFSPathUNICODE :: proc(pathType: WinRT_Path) -> ^u16 ---
  61. WinRTGetFSPathUTF8 :: proc(pathType: WinRT_Path) -> cstring ---
  62. WinRTGetDeviceFamily :: proc() -> WinRT_DeviceFamily ---
  63. }
  64. // Linux
  65. @(default_calling_convention="c", link_prefix="SDL_")
  66. foreign lib {
  67. LinuxSetThreadPriority :: proc(threadID: i64, priority: c.int) -> c.int ---
  68. }
  69. // iOS
  70. iOSSetAnimationCallback :: iPhoneSetAnimationCallback
  71. iOSSetEventPump :: iPhoneSetEventPump
  72. @(default_calling_convention="c", link_prefix="SDL_")
  73. foreign lib {
  74. iPhoneSetAnimationCallback :: proc(window: ^Window, interval: c.int, callback: proc "c" (rawptr), callbackParam: rawptr) -> c.int ---
  75. iPhoneSetEventPump :: proc(enabled: bool) ---
  76. }
  77. // Android
  78. ANDROID_EXTERNAL_STORAGE_READ :: 0x01
  79. ANDROID_EXTERNAL_STORAGE_WRITE :: 0x02
  80. @(default_calling_convention="c", link_prefix="SDL_")
  81. foreign lib {
  82. AndroidGetJNIEnv :: proc() -> rawptr ---
  83. AndroidGetActivity :: proc() -> rawptr ---
  84. GetAndroidSDKVersion :: proc() -> c.int ---
  85. IsAndroidTV :: proc() -> bool ---
  86. IsChromebook :: proc() -> bool ---
  87. IsDeXMode :: proc() -> bool ---
  88. AndroidBackButton :: proc() ---
  89. AndroidGetInternalStoragePath :: proc() -> cstring ---
  90. AndroidGetExternalStorageState :: proc() -> c.int ---
  91. AndroidGetExternalStoragePath :: proc() -> cstring ---
  92. AndroidRequestPermission :: proc(permission: cstring) -> bool ---
  93. AndroidShowToast :: proc(message: cstring, duration, gravity, xoffset, yoffset: c.int) -> c.int ---
  94. }