private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size((float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size((float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider(m_username, false)); DrawingSurface.SetManipulationHandler(m_d3dInterop); m_d3dInterop.setWinRtCallback(new WinRtCallback(ProcessCallback)); string preGameUpdate = "{\"" + EVENT_TYPE + "\":" + PRE_GAME + ",\"" + PHASE + "\":" + CONNECTING + "}"; Deployment.Current.Dispatcher.BeginInvoke(() => { m_d3dInterop.onChatReceived(preGameUpdate); WarpClient.GetInstance().AddConnectionRequestListener(m_connectionRequestListener); WarpClient.GetInstance().AddNotificationListener(m_notifyListener); WarpClient.GetInstance().Connect(m_username, AppWarpConstants.APPWARP_AUTH_DATA); }); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty); DisplayOrientations displayOrientation = ConvertToNativeOrientation(pageOrientation); m_d3dInterop = new Direct3DInterop(displayOrientation); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Set the preferred device orientation m_d3dInterop.WindowOrientation = DisplayOrientations.Landscape; // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); } }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); } }
public override void Draw(GameTime gameTime) { foreach (VideoComponent videoComponent in Components) { MediaPlayer mediaPlayer = videoComponent.MediaPlayer; if (mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing) { if (videoComponent.Target != null) { using Vortice.Direct3D11.ID3D11On12Device device11On12 = ((Vortice.Direct3D11.ID3D11Device)GraphicsDevice.Direct3D11Device).QueryInterface <Vortice.Direct3D11.ID3D11On12Device>(); var d3D11RenderTarget = device11On12.CreateWrappedResource( videoComponent.Target.NativeResource, new Vortice.Direct3D11.ResourceFlags { BindFlags = (int)Direct3DBindings.ShaderResource }, (int)Vortice.Direct3D12.ResourceStates.CopyDestination, (int)Vortice.Direct3D12.ResourceStates.CopyDestination); using (Vortice.DXGI.IDXGISurface dxgiSurface = d3D11RenderTarget.QueryInterface <Vortice.DXGI.IDXGISurface>()) { IDirect3DSurface surface = Direct3DInterop.CreateDirect3DSurface(dxgiSurface); mediaPlayer.CopyFrameToVideoSurface(surface); } device11On12.ReleaseWrappedResources(d3D11RenderTarget); } } } }
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(); }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); EditBoxDelegate editBoxDelegate = new EditBoxDelegate(); EditBoxImpl editBoxImpl = new EditBoxImpl(); editBoxImpl.setMainPage(this); editBoxImpl.setD3dInterop(m_d3dInterop); editBoxDelegate.SetCallback(editBoxImpl); } }
public DirectXMenager() { Interop = new Direct3DInterop(); Interop.AddToObjectMonitor("Interop"); Interop.ConnectEvent += m_d3dInterop_ConnectEvent; Interop.DisconnectEvent += m_d3dInterop_DisconnectEvent; }
private ID3D11Texture2D GetHolographicBackBuffer() { HolographicSurface = HolographicFrame.GetRenderingParameters(HolographicFrame.CurrentPrediction.CameraPoses[0]).Direct3D11BackBuffer; using IDXGISurface surface = Direct3DInterop.CreateDXGISurface(HolographicSurface); ID3D11Texture2D d3DBackBuffer = new ID3D11Texture2D(surface.NativePointer); PresentationParameters.BackBufferFormat = (PixelFormat)d3DBackBuffer.Description.Format; PresentationParameters.BackBufferWidth = d3DBackBuffer.Description.Width; PresentationParameters.BackBufferHeight = d3DBackBuffer.Description.Height; return(d3DBackBuffer); }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty); DisplayOrientations displayOrientation; switch (pageOrientation) { case PageOrientation.Portrait: case PageOrientation.PortraitUp: displayOrientation = DisplayOrientations.Portrait; break; case PageOrientation.PortraitDown: displayOrientation = DisplayOrientations.PortraitFlipped; break; case PageOrientation.Landscape: case PageOrientation.LandscapeLeft: displayOrientation = DisplayOrientations.Landscape; break; case PageOrientation.LandscapeRight: displayOrientation = DisplayOrientations.LandscapeFlipped; break; default: displayOrientation = DisplayOrientations.Landscape; break; } m_d3dInterop = new Direct3DInterop(displayOrientation); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty); DisplayOrientations displayOrientation; switch(pageOrientation) { case PageOrientation.Portrait: case PageOrientation.PortraitUp: displayOrientation = DisplayOrientations.Portrait; break; case PageOrientation.PortraitDown: displayOrientation = DisplayOrientations.PortraitFlipped; break; case PageOrientation.Landscape: case PageOrientation.LandscapeLeft: displayOrientation = DisplayOrientations.Landscape; break; case PageOrientation.LandscapeRight: displayOrientation = DisplayOrientations.LandscapeFlipped; break; default: displayOrientation = DisplayOrientations.Landscape; break; } m_d3dInterop = new Direct3DInterop(displayOrientation); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL); } }
private void drawingSurfacebg_Loaded(object sender, RoutedEventArgs e) { cb = new ONSCL_Callback(this); if (m_d3dBackground == null) { m_d3dBackground = new Direct3DInterop(gamefolder); //横屏 double deviceh = Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0); double devicew = Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0); double xamlh = Application.Current.Host.Content.ActualWidth; double xamlw = Application.Current.Host.Content.ActualHeight; switch (ONSCL_GameInfoPage.nsg.screentype) { case 1: m_d3dBackground.SetONSResolutionAndDisplayMode((int)deviceh * 4 / 3, (int)deviceh, 640, 480, 0xF); drawingSurfacebg.Width = 640; break; case 2: m_d3dBackground.SetONSResolutionAndDisplayMode((int)devicew, (int)devicew * 3 / 4, 800, 600, 0xFF); RenderArea.Margin = new Thickness(0, 0, 0, -200); drawingSurfacebg.Height = 600; drawingSurfacebg.VerticalAlignment = VerticalAlignment.Top; break; } m_d3dBackground.InitGlobalCallback(cb); // 设置窗口边界(以 dip 为单位) m_d3dBackground.WindowBounds = new Windows.Foundation.Size(xamlw, xamlh); // 设置本机分辨率(以像素为单位) m_d3dBackground.NativeResolution = new Windows.Foundation.Size(devicew, deviceh); // 将呈现分辨率设置为本机的最大分辨率 m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution; // 将本机组件挂钩到 DrawingSurfaceBackgroundGrid drawingSurfacebg.SetContentProvider(m_d3dBackground.CreateContentProvider()); drawingSurfacebg.SetManipulationHandler(m_d3dBackground); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); m_d3dInterop.WindowOrientation = DisplayOrientations.Portrait; } }
/* * private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) * { * if (m_d3dInterop == null) * { * m_d3dInterop = new Direct3DInterop(); * * * // Задание границ окна в аппаратно-независимых пикселях (DIP) * m_d3dInterop.WindowBounds = new Windows.Foundation.Size( * (float)DrawingSurface.ActualWidth, * (float)DrawingSurface.ActualHeight * ); * * // Задание собственного разрешения в пикселях * m_d3dInterop.NativeResolution = new Windows.Foundation.Size( * (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), * (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) * ); * * // Задание для разрешения отрисовки значения полного собственного разрешения * m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; * * // Присоединение собственного компонента к DrawingSurface * DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); * DrawingSurface.SetManipulationHandler(m_d3dInterop); * } * } */ private void DrawingSurfaceBackground_Loaded() { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateBackgroundContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); m_d3dInterop.WindowOrientation = DisplayOrientations.Portrait; } }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); } }
private void SetContentProvider(byte[] asset) { try { _interop = new Direct3DInterop(asset); // Set native resolution in pixels _interop.WindowBounds = _interop.RenderResolution = _interop.NativeResolution = new Windows.Foundation.Size(_interop.Width, _interop.Height); image.Height = _interop.Height; image.Width = _interop.Width; // Hook-up native component to DrawingSurface if (_loaded) { image.SetContentProvider(_interop.CreateContentProvider()); CoerceScale(true); ResizeImage(true); } } catch { ServiceLocator.Current.GetInstance<INotificationService>().CreateNotification("Invalid Gif detected"); } }
private async void SetContentProvider(string sourceUrl) { Monitor.Enter(this); try { if (_interop != null) return; Messenger.Default.Send<LoadingMessage>(new LoadingMessage { Loading = true }); var asset = await SimpleHttpService.GetBytes(sourceUrl); if (asset == null) return; _interop = new Direct3DInterop(asset); // Set native resolution in pixels _interop.RenderResolution = _interop.NativeResolution = _interop.WindowBounds = new Windows.Foundation.Size(_interop.Width, _interop.Height); image.Height = _interop.Height; image.Width = _interop.Width; // Hook-up native component to DrawingSurface image.SetContentProvider(_interop.CreateContentProvider()); _scale = 0; CoerceScale(true); _scale = _coercedScale; ResizeImage(true); } catch { } finally { Messenger.Default.Send<LoadingMessage>(new LoadingMessage { Loading = false }); Monitor.Exit(this); } }
public void setD3dInterop(Direct3DInterop d3dInterop) { m_d3dInterop = d3dInterop; }