Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            this.Loaded += delegate
            {
                if (UseOculusRift)
                {
                    // Create Oculus OVR Wrapper
                    _ovr = OvrWrap.Create();

                    // Check if OVR service is running
                    var detectResult = _ovr.Detect(0);

                    if (!detectResult.IsOculusServiceRunning)
                    {
                        MessageBox.Show("Oculus service is not running", "Oculus error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    // Check if Head Mounter Display is connected
                    if (!detectResult.IsOculusHMDConnected)
                    {
                        MessageBox.Show("Oculus HMD (Head Mounter Display) is not connected", "Oculus error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }

                InitializeOvrAndDirectX();
            };

            this.Closing += delegate(object sender, CancelEventArgs args)
            {
                if (!RenderAt90Fps)
                {
                    CompositionTarget.Rendering -= CompositionTargetOnRendering; // Stop rendering at 60 FPS
                }
                if (_xInputCameraController != null)
                {
                    _xInputCameraController.StopCheckingController();
                }

                Dispose();
            };
        }