コード例 #1
0
	void Update()
	{
		if (text != null)
		{
			if (Input.GetKeyDown(KeyCode.I))
			{
				text.enabled = !text.enabled;
			}

			if (text.enabled)
			{
				var vr = SteamVR.instance;
				if (vr != null)
				{
					var timing = new Valve.VR.Compositor_FrameTiming();
					timing.size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Valve.VR.Compositor_FrameTiming));
					vr.compositor.GetFrameTiming(ref timing, 0);

					var update = timing.frameStart + timing.frameVSync;
					if (update > lastUpdate)
					{
						var framerate = (lastUpdate > 0.0f) ? 1.0f / (update - lastUpdate) : 0.0f;
						lastUpdate = update;
						text.text = string.Format("framerate: {0:N0}\ndropped frames: {1}", framerate, (int)timing.droppedFrames);
					}
					else
					{
						lastUpdate = update;
					}
				}
			}
		}
	}
コード例 #2
0
	void Update()
	{
		if (text != null)
		{
			if (Input.GetKeyDown(KeyCode.I))
			{
				text.enabled = !text.enabled;
			}

			if (text.enabled)
			{
				var compositor = OpenVR.Compositor;
				if (compositor != null)
				{
					var timing = new Compositor_FrameTiming();
					timing.m_nSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming));
					compositor.GetFrameTiming(ref timing, 0);

					var update = timing.m_flSystemTimeInSeconds;
					if (update > lastUpdate)
					{
						var framerate = (lastUpdate > 0.0f) ? 1.0f / (update - lastUpdate) : 0.0f;
						lastUpdate = update;
						text.text = string.Format("framerate: {0:N0}\ndropped frames: {1}", framerate, (int)timing.m_nNumDroppedFrames);
					}
					else
					{
						lastUpdate = update;
					}
				}
			}
		}
	}
コード例 #3
0
ファイル: SteamVR_Stats.cs プロジェクト: Nturibi/valentinesVR
    void Update()
    {
        if (text != null)
        {
            if (Input.GetKeyDown(KeyCode.I))
            {
                text.enabled = !text.enabled;
            }

            if (text.enabled)
            {
                var vr = SteamVR.instance;
                if (vr != null)
                {
                    var timing = new Valve.VR.Compositor_FrameTiming();
                    timing.size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Valve.VR.Compositor_FrameTiming));
                    vr.compositor.GetFrameTiming(ref timing, 0);

                    var update = timing.frameStart + timing.frameVSync;
                    if (update > lastUpdate)
                    {
                        var framerate = (lastUpdate > 0.0f) ? 1.0f / (update - lastUpdate) : 0.0f;
                        lastUpdate = update;
                        text.text  = string.Format("framerate: {0:N0}\ndropped frames: {1}", framerate, (int)timing.droppedFrames);
                    }
                    else
                    {
                        lastUpdate = update;
                    }
                }
            }
        }
    }
コード例 #4
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public abstract bool GetFrameTiming(ref Compositor_FrameTiming pTiming,uint unFramesAgo);
コード例 #5
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	internal static extern bool VR_IVRCompositor_GetFrameTiming(IntPtr instancePtr, ref Compositor_FrameTiming pTiming, uint unFramesAgo);
コード例 #6
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public override bool GetFrameTiming(ref Compositor_FrameTiming pTiming,uint unFramesAgo)
	{
		CheckIfUsable();
		bool result = VRNativeEntrypoints.VR_IVRCompositor_GetFrameTiming(m_pVRCompositor,ref pTiming,unFramesAgo);
		return result;
	}
コード例 #7
0
 // Token: 0x06001F5C RID: 8028 RVA: 0x0009D616 File Offset: 0x0009B816
 public uint GetFrameTimings(ref Compositor_FrameTiming pTiming, uint nFrames)
 {
     return(this.FnTable.GetFrameTimings(ref pTiming, nFrames));
 }
コード例 #8
0
 // Token: 0x06001F5B RID: 8027 RVA: 0x0009D602 File Offset: 0x0009B802
 public bool GetFrameTiming(ref Compositor_FrameTiming pTiming, uint unFramesAgo)
 {
     return(this.FnTable.GetFrameTiming(ref pTiming, unFramesAgo));
 }
コード例 #9
0
        void Update()
        {
            if (SteamVR.active == false)
            {
                return;
            }

            UpdatePoses();

            // Dispatch any OpenVR events.
            var system = OpenVR.System;

            if (system != null)
            {
                var vrEvent = new VREvent_t();
                var size    = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t));
                for (int i = 0; i < 64; i++)
                {
                    if (!system.PollNextEvent(ref vrEvent, size))
                    {
                        break;
                    }

                    switch ((EVREventType)vrEvent.eventType)
                    {
                    case EVREventType.VREvent_InputFocusCaptured:     // another app has taken focus (likely dashboard)
                        if (vrEvent.data.process.oldPid == 0)
                        {
                            SteamVR_Events.InputFocus.Send(false);
                        }

                        break;

                    case EVREventType.VREvent_InputFocusReleased:     // that app has released input focus
                        if (vrEvent.data.process.pid == 0)
                        {
                            SteamVR_Events.InputFocus.Send(true);
                        }

                        break;

                    case EVREventType.VREvent_ShowRenderModels:
                        SteamVR_Events.HideRenderModels.Send(false);
                        break;

                    case EVREventType.VREvent_HideRenderModels:
                        SteamVR_Events.HideRenderModels.Send(true);
                        break;

                    default:
                        SteamVR_Events.System((EVREventType)vrEvent.eventType).Send(vrEvent);
                        break;
                    }
                }
            }

            // Ensure various settings to minimize latency.
            Application.targetFrameRate     = -1;
            Application.runInBackground     = true; // don't require companion window focus
            QualitySettings.maxQueuedFrames = -1;
            QualitySettings.vSyncCount      = 0;    // this applies to the companion window

            if (SteamVR.settings.lockPhysicsUpdateRateToRenderFrequency && Time.timeScale > 0.0f)
            {
                var vr = SteamVR.instance;
                if (vr != null)
                {
                    var timing = new Compositor_FrameTiming();
                    timing.m_nSize =
                        (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming));
                    vr.compositor.GetFrameTiming(ref timing, 0);

                    Time.fixedDeltaTime = Time.timeScale / vr.hmd_DisplayFrequency;
                }
            }
        }
コード例 #10
0
ファイル: SteamVR_Render.cs プロジェクト: ConstLiu/openvr
    void Update()
    {
        #if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
        if (poseUpdater == null)
        {
            var go = new GameObject("poseUpdater");
            go.transform.parent = transform;
            poseUpdater = go.AddComponent<SteamVR_UpdatePoses>();
        }
        #else
        if (cameras.Length == 0)
        {
            enabled = false;
            return;
        }

        // If our FixedUpdate rate doesn't match our render framerate, then catch the handoff here.
        SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_PostPresentHandoff);
        #endif
        // Force controller update in case no one else called this frame to ensure prevState gets updated.
        SteamVR_Controller.Update();

        // Dispatch any OpenVR events.
        var system = OpenVR.System;
        if (system != null)
        {
            var vrEvent = new VREvent_t();
            var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t));
            for (int i = 0; i < 64; i++)
            {
                if (!system.PollNextEvent(ref vrEvent, size))
                    break;

                switch ((EVREventType)vrEvent.eventType)
                {
                    case EVREventType.VREvent_InputFocusCaptured: // another app has taken focus (likely dashboard)
                        if (vrEvent.data.process.oldPid == 0)
                        {
                            SteamVR_Utils.Event.Send("input_focus", false);
                        }
                        break;
                    case EVREventType.VREvent_InputFocusReleased: // that app has released input focus
                        if (vrEvent.data.process.pid == 0)
                        {
                            SteamVR_Utils.Event.Send("input_focus", true);
                        }
                        break;
                    case EVREventType.VREvent_ShowRenderModels:
                        SteamVR_Utils.Event.Send("hide_render_models", false);
                        break;
                    case EVREventType.VREvent_HideRenderModels:
                        SteamVR_Utils.Event.Send("hide_render_models", true);
                        break;
                    default:
                        var name = System.Enum.GetName(typeof(EVREventType), vrEvent.eventType);
                        if (name != null)
                            SteamVR_Utils.Event.Send(name.Substring(8) /*strip VREvent_*/, vrEvent);
                        break;
                }
            }
        }

        // Ensure various settings to minimize latency.
        Application.targetFrameRate = -1;
        Application.runInBackground = true; // don't require companion window focus
        QualitySettings.maxQueuedFrames = -1;
        QualitySettings.vSyncCount = 0; // this applies to the companion window

        if (lockPhysicsUpdateRateToRenderFrequency && Time.timeScale > 0.0f)
        {
            var vr = SteamVR.instance;
            if (vr != null)
            {
                var timing = new Compositor_FrameTiming();
                timing.m_nSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming));
                vr.compositor.GetFrameTiming(ref timing, 0);

                Time.fixedDeltaTime = Time.timeScale / vr.hmd_DisplayFrequency;
                Time.maximumDeltaTime = Time.fixedDeltaTime * timing.m_nNumFramePresents;
            }
        }
    }
コード例 #11
0
	public bool GetFrameTiming(ref Compositor_FrameTiming pTiming,uint unFramesAgo)
	{
		bool result = FnTable.GetFrameTiming(ref pTiming,unFramesAgo);
		return result;
	}
コード例 #12
0
 public static bool GetFrameTiming(ref Compositor_FrameTiming pTiming, uint unFramesAgo)
 {
     pTiming.m_nSize = (uint)Marshal.SizeOf(pTiming);
     if (m_vrCompositor!=null)
         return m_vrCompositor.GetFrameTiming(ref pTiming, unFramesAgo);
     return false;
 }
コード例 #13
0
ファイル: CVRCompositor.cs プロジェクト: GameDiffs/TheForest
 public bool GetFrameTiming(ref Compositor_FrameTiming pTiming, uint unFramesAgo)
 {
     return this.FnTable.GetFrameTiming(ref pTiming, unFramesAgo);
 }
コード例 #14
0
 public bool GetFrameTiming(ref Compositor_FrameTiming pTiming, uint unFramesAgo) => default; // 0x00000001811DD5F0-0x00000001811DD610
 public uint GetFrameTimings(ref Compositor_FrameTiming pTiming, uint nFrames) => default;    // 0x00000001811DD610-0x00000001811DD630
コード例 #15
0
        }                                                                                            // 0x00000001811DD870-0x00000001811DD890

        public bool GetFrameTiming(ref Compositor_FrameTiming pTiming, uint unFramesAgo) => default; // 0x00000001811DD5F0-0x00000001811DD610