IUnityGraphics.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Unity Native Plugin API copyright © 2015 Unity Technologies ApS
  2. //
  3. // Licensed under the Unity Companion License for Unity - dependent projects--see[Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
  4. //
  5. // Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.Please review the license for details on these and other terms and conditions.
  6. #pragma once
  7. #include "IUnityInterface.h"
  8. typedef enum UnityGfxRenderer
  9. {
  10. //kUnityGfxRendererOpenGL = 0, // Legacy OpenGL, removed
  11. //kUnityGfxRendererD3D9 = 1, // Direct3D 9, removed
  12. kUnityGfxRendererD3D11 = 2, // Direct3D 11
  13. kUnityGfxRendererNull = 4, // "null" device (used in batch mode)
  14. kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0
  15. kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0
  16. //kUnityGfxRendererGXM = 12, // PlayStation Vita, removed
  17. kUnityGfxRendererPS4 = 13, // PlayStation 4
  18. kUnityGfxRendererXboxOne = 14, // Xbox One
  19. kUnityGfxRendererMetal = 16, // iOS Metal
  20. kUnityGfxRendererOpenGLCore = 17, // OpenGL core
  21. kUnityGfxRendererD3D12 = 18, // Direct3D 12
  22. kUnityGfxRendererVulkan = 21, // Vulkan
  23. kUnityGfxRendererNvn = 22, // Nintendo Switch NVN API
  24. kUnityGfxRendererXboxOneD3D12 = 23 // MS XboxOne Direct3D 12
  25. } UnityGfxRenderer;
  26. typedef enum UnityGfxDeviceEventType
  27. {
  28. kUnityGfxDeviceEventInitialize = 0,
  29. kUnityGfxDeviceEventShutdown = 1,
  30. kUnityGfxDeviceEventBeforeReset = 2,
  31. kUnityGfxDeviceEventAfterReset = 3,
  32. } UnityGfxDeviceEventType;
  33. typedef void (UNITY_INTERFACE_API * IUnityGraphicsDeviceEventCallback)(UnityGfxDeviceEventType eventType);
  34. // Should only be used on the rendering thread unless noted otherwise.
  35. UNITY_DECLARE_INTERFACE(IUnityGraphics)
  36. {
  37. UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)(); // Thread safe
  38. // This callback will be called when graphics device is created, destroyed, reset, etc.
  39. // It is possible to miss the kUnityGfxDeviceEventInitialize event in case plugin is loaded at a later time,
  40. // when the graphics device is already created.
  41. void(UNITY_INTERFACE_API * RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  42. void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback);
  43. int(UNITY_INTERFACE_API * ReserveEventIDRange)(int count); // reserves 'count' event IDs. Plugins should use the result as a base index when issuing events back and forth to avoid event id clashes.
  44. };
  45. UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL, 0x8C5AD4926EB17B11ULL, IUnityGraphics)
  46. // Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can callback into native plugins.
  47. // Provide them with an address to a function of this signature.
  48. typedef void (UNITY_INTERFACE_API * UnityRenderingEvent)(int eventId);
  49. typedef void (UNITY_INTERFACE_API * UnityRenderingEventAndData)(int eventId, void* data);