| 1 | namespace Oculus.Platform |
| 2 | { |
| 3 | using UnityEngine; |
| 4 | using System; |
| 5 | using System.Collections; |
| 6 | using System.Runtime.InteropServices; |
| 7 | |
| 8 | public class WindowsPlatform |
| 9 | { |
| 10 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
| 11 | public delegate void UnityLogDelegate(IntPtr tag, IntPtr msg); |
| 12 | |
| 13 | void CPPLogCallback(IntPtr tag, IntPtr message) |
| 14 | { |
| 15 | Debug.Log(string.Format("{0}: {1}", Marshal.PtrToStringAnsi(tag), Marshal.PtrToStringAnsi(message))); |
| 16 | } |
| 17 | |
| 18 | IntPtr getCallbackPointer() |
| 19 | { |
| 20 | //UnityLogDelegate callback_delegate = new UnityLogDelegate(CPPLogCallback); |
| 21 | //IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(callback_delegate); |
| 22 | return IntPtr.Zero; |
| 23 | } |
| 24 | |
| 25 | public bool Initialize(string appId) |
| 26 | { |
| 27 | if(String.IsNullOrEmpty(appId)) |
| 28 | { |
| 29 | throw new UnityException("AppID must not be null or empty"); |
| 30 | } |
| 31 | |
| 32 | CAPI.ovr_UnityInitWrapperWindows(appId, getCallbackPointer()); |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | public Request<Models.PlatformInitialize> AsyncInitialize(string appId) |
| 37 | { |
| 38 | if(String.IsNullOrEmpty(appId)) |
| 39 | { |
| 40 | throw new UnityException("AppID must not be null or empty"); |
| 41 | } |
| 42 | |
| 43 | return new Request<Models.PlatformInitialize>(CAPI.ovr_UnityInitWrapperWindowsAsynchronous(appId, getCallbackPointer())); |
| 44 | } |
| 45 | } |
| 46 | } |