public HolographicGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters, HolographicSpace holographicSpace) : base(device, presentationParameters) { if (GraphicsDevice.RenderTargetViewAllocator.DescriptorHeap.Description.DescriptorCount != BufferCount) { GraphicsDevice.RenderTargetViewAllocator.Dispose(); GraphicsDevice.RenderTargetViewAllocator = new DescriptorAllocator(GraphicsDevice, DescriptorHeapType.RenderTargetView, descriptorCount: BufferCount); } using (IDXGIDevice dxgiDevice = GraphicsDevice.NativeDirect3D11Device.QueryInterface <IDXGIDevice>()) { IDirect3DDevice direct3DInteropDevice = Direct3DInterop.CreateDirect3DDevice(dxgiDevice); HolographicSpace = holographicSpace; HolographicSpace.SetDirect3D11Device(direct3DInteropDevice); } HolographicDisplay = HolographicDisplay.GetDefault(); SpatialStationaryFrameOfReference = HolographicDisplay.SpatialLocator.CreateStationaryFrameOfReferenceAtCurrentLocation(); HolographicFrame = HolographicSpace.CreateNextFrame(); HolographicSurface = HolographicFrame.GetRenderingParameters(HolographicFrame.CurrentPrediction.CameraPoses[0]).Direct3D11BackBuffer; HolographicBackBuffer = GetHolographicBackBuffer(); renderTarget = CreateRenderTarget(); direct3D11RenderTarget = CreateDirect3D11RenderTarget(); }
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; PresentationParameters.Stereo = HolographicDisplay.GetDefault().IsStereo; }
void OnHolographicDisplayIsAvailableChanged(Object o, Object args) { // Get the spatial locator for the default HolographicDisplay, if one is available. SpatialLocator spatialLocator = null; if (canGetDefaultHolographicDisplay) { HolographicDisplay defaultHolographicDisplay = HolographicDisplay.GetDefault(); if (defaultHolographicDisplay != null) { spatialLocator = defaultHolographicDisplay.SpatialLocator; } } else { spatialLocator = SpatialLocator.GetDefault(); } if (this.spatialLocator != spatialLocator) { // If the spatial locator is disconnected or replaced, we should discard any state that was // based on it. if (this.spatialLocator != null) { this.spatialLocator.LocatabilityChanged -= this.OnLocatabilityChanged; this.spatialLocator = null; } this.stationaryReferenceFrame = null; if (spatialLocator != null) { // Use the SpatialLocator from the default HolographicDisplay to track the motion of the device. this.spatialLocator = spatialLocator; // Respond to changes in the positional tracking state. this.spatialLocator.LocatabilityChanged += this.OnLocatabilityChanged; // The simplest way to render world-locked holograms is to create a stationary reference frame // based on a SpatialLocator. This is roughly analogous to creating a "world" coordinate system // with the origin placed at the device's position as the app is launched. this.stationaryReferenceFrame = this.spatialLocator.CreateStationaryFrameOfReferenceAtCurrentLocation(); } } }