Skip to content

Fixed WSA compilation and added compatibility with Unity 2017 #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions OSVR-Unity/Assets/OSVRUnity/src/OsvrRenderManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ private struct OSVR_ViewportDescription
private static readonly IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(debugLog);
private static void DebugWrapper(string log) { Debug.Log(log); }

#if UNITY_METRO
private static Byte ConstructRenderBuffers() { return 0; }
private static Byte CreateRenderManagerFromUnity(OSVR.ClientKit.SafeClientContextHandle ctx) { return 0; }
private static OSVR.ClientKit.Pose3 GetEyePose(int eye) { return new OSVR.ClientKit.Pose3(); }
private static OSVR_ProjectionMatrix GetProjectionMatrix(int eye) { return new OSVR_ProjectionMatrix(); }
private static IntPtr GetRenderEventFunc() { return IntPtr.Zero; }
private static OSVR_ViewportDescription GetViewport(int eye) { return new OSVR_ViewportDescription(); }
private static void LinkDebug([MarshalAs(UnmanagedType.FunctionPtr)]IntPtr debugCal) { }
private static int SetColorBufferFromUnity(System.IntPtr texturePtr, int eye) { return 0; }
private static void SetFarClipDistance(double farClipPlaneDistance) { }
private static void SetIPD(double ipdMeters) { }
private static void SetNearClipDistance(double nearClipPlaneDistance) { }
private static void ShutdownRenderManager() { }
#else

//Create and Register RenderBuffers
[DllImport(PluginName)]
private static extern Byte
Expand Down Expand Up @@ -127,6 +142,8 @@ private static extern void
private static extern void
ShutdownRenderManager();

#endif

// UnityPluginLoad is not needed
// UnityPluginUnload is not needed

Expand Down Expand Up @@ -220,7 +237,7 @@ public void SetIPDMeters(float ipd)
//"Recenter" based on current head orientation
public void SetRoomRotationUsingHead()
{
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2017
ClientKit.instance.context.SetRoomRotationUsingHead();
GL.IssuePluginEvent(GetRenderEventFunc(), 3);
#endif
Expand All @@ -229,7 +246,7 @@ public void SetRoomRotationUsingHead()
//Clear the room-to-world transform, undo a call to SetRoomRotationUsingHead
public void ClearRoomToWorldTransform()
{
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2017
ClientKit.instance.context.ClearRoomToWorldTransform();
GL.IssuePluginEvent(GetRenderEventFunc(), 4);
#endif
Expand Down
4 changes: 2 additions & 2 deletions OSVR-Unity/Assets/OSVRUnity/src/VRViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void UpdateEyes()
if (DisplayController.UseRenderManager)
{
//Update RenderInfo
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2017
GL.IssuePluginEvent(DisplayController.RenderManager.GetRenderEventFunction(), OsvrRenderManager.UPDATE_RENDERINFO_EVENT);
#else
Debug.LogError("[OSVR-Unity] GL.IssuePluginEvent failed. This version of Unity cannot support RenderManager.");
Expand Down Expand Up @@ -292,7 +292,7 @@ IEnumerator EndOfFrame()
if (DisplayController.UseRenderManager && DisplayController.CheckDisplayStartup())
{
// Issue a RenderEvent, which copies Unity RenderTextures to RenderManager buffers
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6
#if UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6|| UNITY_2017
GL.Viewport(_emptyViewport);
GL.Clear(false, true, Camera.backgroundColor);
GL.IssuePluginEvent(DisplayController.RenderManager.GetRenderEventFunction(), OsvrRenderManager.RENDER_EVENT);
Expand Down