Exemplo n.º 1
0
        /// <summary>
        /// Called when the CoreWindow object is created (or re-created).
        /// </summary>
        public void SetWindow(CoreWindow window)
        {
            // Register for keypress notifications.
            window.KeyDown += this.OnKeyPressed;

            // Register for notification that the app window is being closed.
            window.Closed += this.OnWindowClosed;

            // Register for notifications that the app window is losing focus.
            window.VisibilityChanged += this.OnVisibilityChanged;

            // Create a holographic space for the core window for the current view.
            // Presenting holographic frames that are created by this holographic space will put
            // the app into exclusive mode.
            holographicSpace = HolographicSpace.CreateForCoreWindow(window);

            // The DeviceResources class uses the preferred DXGI adapter ID from the holographic
            // space (when available) to create a Direct3D device. The HolographicSpace
            // uses this ID3D11Device to create and manage device-based resources such as
            // swap chains.
            deviceResources.SetHolographicSpace(holographicSpace);

            // The main class uses the holographic space for updates and rendering.
            main.SetHolographicSpace(holographicSpace);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called when the CoreWindow object is created (or re-created).
 /// </summary>
 public void SetWindow(CoreWindow window)
 {
     window.KeyDown           += this.OnKeyPressed;
     window.Closed            += this.OnWindowClosed;
     window.VisibilityChanged += this.OnVisibilityChanged;
     HolographicSpace          = HolographicSpace.CreateForCoreWindow(window);
 }
Exemplo n.º 3
0
        public WindowsMixedRealityGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters)
            : base(device, presentationParameters)
        {
            holographicSpace = HolographicSpace.CreateForCoreWindow(CoreWindow.GetForCurrentThread());
            CoreWindow.GetForCurrentThread().Activate();

            Device3         d3DDevice        = device.NativeDevice.QueryInterface <Device3>();
            IDirect3DDevice d3DInteropDevice = null;

            // Acquire the DXGI interface for the Direct3D device.
            using (var dxgiDevice = d3DDevice.QueryInterface <SharpDX.DXGI.Device3>())
            {
                // Wrap the native device using a WinRT interop object.
                uint hr = CreateDirect3D11DeviceFromDXGIDevice(dxgiDevice.NativePointer, out IntPtr pUnknown);

                if (hr == 0)
                {
                    d3DInteropDevice = Marshal.GetObjectForIUnknown(pUnknown) as IDirect3DDevice;
                    Marshal.Release(pUnknown);
                }
            }

            holographicSpace.SetDirect3D11Device(d3DInteropDevice);

            BeginDraw(null);
            ResizeDepthStencilBuffer(backBuffer.Width, backBuffer.Height, 0);

            // Set a dummy back buffer as we use a seperate one for each eye.
            BackBuffer = Texture.New(GraphicsDevice, backBuffer.Description, null);
        }
Exemplo n.º 4
0
        public HolographicGameContext(HolographicSpace?holographicSpace = null, CoreWindow?control = null)
            : base(control ?? CoreWindow.GetForCurrentThread())
        {
            HolographicSpace = holographicSpace ?? HolographicSpace.CreateForCoreWindow(Control);

            PresentationParameters.BackBufferWidth  = (int)Control.Bounds.Width;
            PresentationParameters.BackBufferHeight = (int)Control.Bounds.Width;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Called when the CoreWindow object is created (or re-created).
 /// </summary>
 public void SetWindow(CoreWindow window)
 {
     window.KeyDown           += OnKeyDown;
     window.KeyUp             += OnKeyUp;
     window.Closed            += OnWindowClosed;
     window.VisibilityChanged += this.OnVisibilityChanged;
     HolographicSpace          = HolographicSpace.CreateForCoreWindow(window);
     WindowIsSet?.Invoke(window);
 }
Exemplo n.º 6
0
        private void ApplicationView_Activated(CoreApplicationView sender, IActivatedEventArgs e)
        {
            if (HolographicApplicationPreview.IsCurrentViewPresentedOnHolographicDisplay())
            {
                HolographicSpace holographicSpace = HolographicSpace.CreateForCoreWindow(sender.CoreWindow);

                gameContext = new HolographicGameContext(holographicSpace);
            }
            else
            {
                gameContext = new CoreWindowGameContext();
            }

            sender.CoreWindow.Activate();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Called when the CoreWindow object is created (or re-created).
        /// </summary>
        public void SetWindow(CoreWindow window)
        {
            ApplicationView.GetForCurrentView().Consolidated += AppView_Consolidated;

            // Register event handlers for app lifecycle.
            CoreApplication.Suspending += this.OnSuspending;
            CoreApplication.Resuming   += this.OnResuming;

            // Register for keypress notifications.
            window.KeyDown += this.OnKeyPressed;

            // Register for notification that the app window is being closed.
            window.Closed += this.OnWindowClosed;

            // Register for notifications that the app window is losing focus.
            window.VisibilityChanged += this.OnVisibilityChanged;

            // At this point we have access to the device and we can create device-dependent
            // resources.
            deviceResources = new DeviceResources();

            main = new _360VideoPlaybackMain(deviceResources);

            // Create a holographic space for the core window for the current view.
            // Presenting holographic frames that are created by this holographic space will put
            // the app into exclusive mode.
            holographicSpace = HolographicSpace.CreateForCoreWindow(window);

            // The DeviceResources class uses the preferred DXGI adapter ID from the holographic
            // space (when available) to create a Direct3D device. The HolographicSpace
            // uses this ID3D11Device to create and manage device-based resources such as
            // swap chains.
            deviceResources.SetHolographicSpace(holographicSpace);

            // The main class uses the holographic space for updates and rendering.
            main.SetHolographicSpace(holographicSpace);

            MediaSource source = MediaSource.CreateFromUri(sourceUri);

            mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;
            mediaPlayer.Source       = source;// Windows.Media.Core.MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/video.mp4"));

            mediaPlayer.IsVideoFrameServerEnabled = true;
            mediaPlayer.IsLoopingEnabled          = true;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Called when the CoreWindow object is created (or re-created).
        /// </summary>
        public void SetWindow(CoreWindow window)
        {
            // Register for keypress notifications.
            window.KeyDown += this.OnKeyPressed;

            // Register for notification that the app window is being closed.
            window.Closed += this.OnWindowClosed;

            // Register for notifications that the app window is losing focus.
            window.VisibilityChanged += this.OnVisibilityChanged;

            // Create a holographic space for the core window for the current view.
            // Presenting holographic frames that are created by this holographic space will put
            // the app into exclusive mode.
            this.holographicSpace = HolographicSpace.CreateForCoreWindow(window);

            // The main class uses the holographic space for updates and rendering.
            this.main.SetHolographicSpace(this.holographicSpace);
            this.main.Initialize();
        }
Exemplo n.º 9
0
        private void InitializeHolographicSpace(CoreWindow targetWindow)
        {
            // Create the holographic space
            m_holoSpace = HolographicSpace.CreateForCoreWindow(targetWindow);

            // The holographic space might need to determine which adapter supports
            // holograms, in which case it will specify a non-zero PrimaryAdapterId.
            int   shiftPos = sizeof(uint);
            ulong id       = (ulong)m_holoSpace.PrimaryAdapterId.LowPart | (((ulong)m_holoSpace.PrimaryAdapterId.HighPart) << shiftPos);

            // Get the device with the luid or get the default device of the current system
            if (id != 0)
            {
                m_hostDevice = GraphicsCore.Current.TryGetDeviceByLuid((long)id);
            }
            if (m_hostDevice == null)
            {
                m_hostDevice = GraphicsCore.Current.DefaultDevice;
            }

            // Acquire the DXGI interface for the Direct3D device.
            D3D11.Device3 d3dDevice = m_hostDevice.Device3D11_3;
            using (var dxgiDevice = d3dDevice.QueryInterface <SharpDX.DXGI.Device3>())
            {
                // Wrap the native device using a WinRT interop object.
                IntPtr pUnknown;
                UInt32 hr = NativeMethods.CreateDirect3D11DeviceFromDXGIDevice(dxgiDevice.NativePointer, out pUnknown);
                if (hr == 0)
                {
                    m_d3dInteropDevice = (MS_D3D11.IDirect3DDevice)Marshal.GetObjectForIUnknown(pUnknown);
                    Marshal.Release(pUnknown);
                }

                // Store a pointer to the DXGI adapter.
                // This is for the case of no preferred DXGI adapter, or fallback to WARP.
                m_dxgiAdapter = dxgiDevice.Adapter.QueryInterface <SharpDX.DXGI.Adapter3>();
            }

            // Set the Direct3D device on the holographic space
            m_holoSpace.SetDirect3D11Device(m_d3dInteropDevice);
        }