Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

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