1
1
#pragma once
2
2
3
- #include " action.h"
4
3
#include " IUnityGraphics.h"
5
- #include " renderAPI .h"
4
+ #include " action .h"
6
5
#include " log.h"
7
- #include < memory >
6
+ #include " renderAPI.h "
8
7
#include < map>
8
+ #include < memory>
9
9
10
10
class Texture ;
11
11
class VertexBuffer ;
12
12
13
-
14
13
extern " C"
15
14
{
16
- // Export function for other native plugin to create interop graphics object
17
-
18
-
19
- // / <summary>
20
- // / Create a texture object for interoperability from a texture pointer of unity
21
- // / </summary>
22
- // / <param name="textureHandle">A pointer of texture with float4 that has been generated with Unity (see function
23
- // / GetNativeTexturePtr https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html) </param>
24
- // / <param name="width">the width of the texture</param>
25
- // / <param name="height">the height of the texture</param>
26
- // / <param name="depth">depth of 0 or 1 are equivalent to a simple texture 2D when it greater than 1 it will be a texture 2D array </param>
27
- UNITY_INTERFACE_EXPORT Texture* CreateTextureInterop (void * textureHandle, int w, int h, int depth);
28
-
29
- // / <summary>
30
- // / Create a vertex buffer object for interoperability from a compute buffer pointer of unity
31
- // / </summary>
32
- // / <param name="bufferHandle">A pointer of computeBuffer with float4 that has been generated with Unity (see function
33
- // / GetNativeBufferPtr https://docs.unity3d.com/ScriptReference/ComputeBuffer.GetNativeBufferPtr.html) </param>
34
- // / <param name="size">the size of the computeBuffer</param>
35
- UNITY_INTERFACE_EXPORT VertexBuffer* CreateVertexBufferInterop (void * bufferHandle, int size);
36
-
37
- // / <summary>
38
- // / Set time for interoperability plugin
39
- // / </summary>
40
- // / <param name="time">new value for time</param>
41
- UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTime (float time);
42
-
15
+ // Export function for other native plugin to create interop graphics object
16
+
43
17
// / <summary>
44
- // / Get time for interoperability plugin
18
+ // / Check if the device and the graphics api are supported
45
19
// / </summary>
46
- // / <returns>the current time</returns>
47
- UNITY_INTERFACE_EXPORT float UNITY_INTERFACE_API GetTime ();
48
-
49
- // / <summary>
50
- // / Return the callback which will be called from render thread
51
- // / </summary>
52
- UNITY_INTERFACE_EXPORT UnityRenderingEvent UNITY_INTERFACE_API GetRenderEventFunc ();
53
-
54
- // / <summary>
55
- // / Function to call when plugin is unloaded, indeed the function UnityUnload doesn't work
56
- // / see https://unity3d.atlassian.net/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2FIN-13513
57
- // / </summary>
58
- UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityShutdown ();
59
-
60
- // / <summary>
61
- // / Initialize log
62
- // / </summary>
63
- UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API StartLog ();
64
-
65
- // / <summary>
66
- // / Register an action in plugin. When an action has been registered these functions (Start, Update, ...)
67
- // / can be called on render thread from Unity with GL.IssuePluginEvent
68
- // / https://docs.unity3d.com/ScriptReference/GL.IssuePluginEvent.html
69
- // / Make sure the register has been initialized with InitializeRegisterActions function
70
- // / </summary>
71
- // / <param name="action">A pointer toward the action that we want to register</param>
72
- // / <returns>the eventId to recover the action that has been registered. To call these functions on render thread you must
73
- // / call GL.IssuePluginEvent with this Id.</returns>
74
- UNITY_INTERFACE_EXPORT size_t UNITY_INTERFACE_API RegisterAction (Action* action);
75
-
76
- // / <summary>
77
- // / Initialize the register of actions, this has to be called before register actions
78
- // / </summary>
79
- // / <param name="reserveCapacity">The default capacity for the register (just for optimization)</param>
80
- UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API InitializeRegisterActions (int reserveCapacity);
20
+ UNITY_INTERFACE_EXPORT bool IsSupported ();
21
+
22
+ // / <summary>
23
+ // / Create a texture object for interoperability from a texture pointer of
24
+ // / unity
25
+ // / </summary>
26
+ // / <param name="textureHandle">A pointer of texture with float4 that has
27
+ // / been generated with Unity (see function GetNativeTexturePtr
28
+ // / https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html)
29
+ // / </param> <param name="width">the width of the texture</param> <param
30
+ // / name="height">the height of the texture</param> <param
31
+ // / name="depth">depth of 0 or 1 are equivalent to a simple texture 2D when
32
+ // / it greater than 1 it will be a texture 2D array </param>
33
+ UNITY_INTERFACE_EXPORT Texture *CreateTextureInterop (void *textureHandle,
34
+ int w, int h,
35
+ int depth);
36
+
37
+ // / <summary>
38
+ // / Create a vertex buffer object for interoperability from a compute buffer
39
+ // / pointer of unity
40
+ // / </summary>
41
+ // / <param name="bufferHandle">A pointer of computeBuffer with float4 that
42
+ // / has been generated with Unity (see function GetNativeBufferPtr
43
+ // / https://docs.unity3d.com/ScriptReference/ComputeBuffer.GetNativeBufferPtr.html)
44
+ // / </param> <param name="size">the size of the computeBuffer</param>
45
+ UNITY_INTERFACE_EXPORT VertexBuffer *CreateVertexBufferInterop (
46
+ void *bufferHandle, int size);
47
+
48
+ // / <summary>
49
+ // / Set time for interoperability plugin
50
+ // / </summary>
51
+ // / <param name="time">new value for time</param>
52
+ UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetTime (float time);
53
+
54
+ // / <summary>
55
+ // / Get time for interoperability plugin
56
+ // / </summary>
57
+ // / <returns>the current time</returns>
58
+ UNITY_INTERFACE_EXPORT float UNITY_INTERFACE_API GetTime ();
59
+
60
+ // / <summary>
61
+ // / Return the callback which will be called from render thread
62
+ // / </summary>
63
+ UNITY_INTERFACE_EXPORT UnityRenderingEvent UNITY_INTERFACE_API
64
+ GetRenderEventFunc ();
65
+
66
+ // / <summary>
67
+ // / Function to call when plugin is unloaded, indeed the function
68
+ // / UnityUnload doesn't work see
69
+ // / https://unity3d.atlassian.net/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2FIN-13513
70
+ // / </summary>
71
+ UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API UnityShutdown ();
72
+
73
+ // / <summary>
74
+ // / Initialize log
75
+ // / </summary>
76
+ UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API StartLog ();
77
+
78
+ // / <summary>
79
+ // / Register an action in plugin. When an action has been registered these
80
+ // / functions (Start, Update, ...) can be called on render thread from Unity
81
+ // / with GL.IssuePluginEvent
82
+ // / https://docs.unity3d.com/ScriptReference/GL.IssuePluginEvent.html
83
+ // / Make sure the register has been initialized with
84
+ // / InitializeRegisterActions function
85
+ // / </summary>
86
+ // / <param name="action">A pointer toward the action that we want to
87
+ // / register</param> <returns>the eventId to recover the action that has
88
+ // / been registered. To call these functions on render thread you must call
89
+ // / GL.IssuePluginEvent with this Id.</returns>
90
+ UNITY_INTERFACE_EXPORT size_t UNITY_INTERFACE_API
91
+ RegisterAction (Action *action);
92
+
93
+ // / <summary>
94
+ // / Initialize the register of actions, this has to be called before
95
+ // / register actions
96
+ // / </summary>
97
+ // / <param name="reserveCapacity">The default capacity for the register
98
+ // / (just for optimization)</param>
99
+ UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API
100
+ InitializeRegisterActions (int reserveCapacity);
81
101
}
82
102
83
-
84
-
85
103
static float _time;
86
104
87
105
// current API used by Unity
88
- static RenderAPI* s_CurrentAPI = NULL ;
106
+ static RenderAPI * s_CurrentAPI = NULL ;
89
107
static UnityGfxRenderer s_DeviceType = kUnityGfxRendererNull ;
90
- static IUnityInterfaces* s_UnityInterfaces = NULL ;
91
- static IUnityGraphics* s_Graphics = NULL ;
108
+ static IUnityInterfaces * s_UnityInterfaces = NULL ;
109
+ static IUnityGraphics * s_Graphics = NULL ;
92
110
93
111
// the register of action
94
- static std::vector<Action*> _registerActions;
112
+ static std::vector<Action *> _registerActions;
95
113
96
114
// defined the key action to use
97
115
static int _keyAction = 0 ;
@@ -103,4 +121,5 @@ static int _keyAction = 0;
103
121
// / <returns></returns>
104
122
static void UNITY_INTERFACE_API OnRenderEvent (int eventID);
105
123
106
- static void UNITY_INTERFACE_API OnGraphicsDeviceEvent (UnityGfxDeviceEventType eventType);
124
+ static void UNITY_INTERFACE_API
125
+ OnGraphicsDeviceEvent (UnityGfxDeviceEventType eventType);
0 commit comments