PlatformBase.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. // Standard base includes, defines that indicate our current platform, etc.
  3. #include <stddef.h>
  4. #if defined(__APPLE__)
  5. #include <TargetConditionals.h>
  6. #endif
  7. // Which platform we are on?
  8. // UNITY_WIN - Windows (regular win32)
  9. // UNITY_OSX - Mac OS X
  10. // UNITY_LINUX - Linux
  11. // UNITY_IOS - iOS
  12. // UNITY_IOS_SIMULATOR - iOS Simulator
  13. // UNITY_ANDROID - Android
  14. // UNITY_METRO - WSA or UWP
  15. // UNITY_WEBGL - WebGL
  16. #if _MSC_VER
  17. #define UNITY_WIN 1
  18. #elif defined(__APPLE__)
  19. #if TARGET_OS_IOS
  20. #define UNITY_IOS 1
  21. #elif TARGET_OS_SIMULATOR
  22. #define UNITY_IOS_SIMULATOR 1
  23. #elif TARGET_OS_OSX
  24. #define UNITY_OSX 1
  25. #endif
  26. #elif defined(__ANDROID__)
  27. #define UNITY_ANDROID 1
  28. #elif defined(__linux__)
  29. #define UNITY_LINUX 1
  30. #elif defined(UNITY_METRO) || defined(UNITY_WEBGL)
  31. // these are defined externally
  32. #elif defined(__EMSCRIPTEN__)
  33. // this is already defined in Unity 5.6
  34. #define UNITY_WEBGL 1
  35. #else
  36. #error "Unknown platform!"
  37. #endif
  38. // Which graphics device APIs we possibly support?
  39. #if UNITY_METRO
  40. #define SUPPORT_D3D11 1
  41. #if WINDOWS_UWP
  42. #define SUPPORT_D3D12 1
  43. #endif
  44. #elif UNITY_WIN
  45. #define SUPPORT_D3D11 1 // comment this out if you don't have D3D11 header/library files
  46. #define SUPPORT_D3D12 1 // comment this out if you don't have D3D12 header/library files
  47. #define SUPPORT_OPENGL_UNIFIED 1
  48. // #define SUPPORT_OPENGL_CORE 1
  49. #define SUPPORT_VULKAN 1 // Requires Vulkan SDK to be installed
  50. #elif UNITY_ANDROID
  51. #ifndef SUPPORT_OPENGL_ES
  52. #define SUPPORT_OPENGL_ES 1
  53. #endif
  54. #define SUPPORT_OPENGL_UNIFIED SUPPORT_OPENGL_ES
  55. #define SUPPORT_VULKAN 1
  56. #elif UNITY_LINUX
  57. #define SUPPORT_OPENGL_UNIFIED 1
  58. #define SUPPORT_OPENGL_CORE 1
  59. #define SUPPORT_VULKAN 1
  60. #endif
  61. #if UNITY_IOS || UNITY_OSX || UNITY_IOS_SIMULATOR
  62. #define SUPPORT_METAL 1
  63. #endif
  64. #if UNITY_LINUX || UNITY_WIN
  65. #define CUDA_PLATFORM 1
  66. #endif
  67. // COM-like Release macro
  68. #ifndef SAFE_RELEASE
  69. #define SAFE_RELEASE(a) if (a) { a->Release(); a = NULL; }
  70. #endif
  71. #ifndef SAFE_CLOSE_HANDLE
  72. #define SAFE_CLOSE_HANDLE(a) if (a) { CloseHandle(a); a = NULL; }
  73. #endif