Beispiel #1
0
        public override void GetTexture(SharpDX.Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out SharpDX.RectangleF textureSubRectangle)
        {
            if (_synchronizedTexture == null)
            {
                _synchronizedTexture = _host.CreateSynchronizedTexture(_controller.GetTexture());
            }

            // Set output parameters.
            _textureSubRectangle.Left   = 0.0f;
            _textureSubRectangle.Top    = 0.0f;
            _textureSubRectangle.Right  = surfaceSize.Width;
            _textureSubRectangle.Bottom = surfaceSize.Height;


            //HOW DO YOU DO A Microsoft::WRL::ComPtr<T>   CopyTo ?????
            //m_synchronizedTexture.CopyTo(synchronizedTexture);
            synchronizedTexture = _synchronizedTexture;

            textureSubRectangle = _textureSubRectangle;

            //something is going wrong here as the second time thru the BeginDraw consumes
            //the call and controlnever returns back to this method, thus GetTexture
            //(the call after begindraw) never fires again... ??????
            synchronizedTexture.BeginDraw();

            _controller.GetTexture(surfaceSize, synchronizedTexture, textureSubRectangle);

            synchronizedTexture.EndDraw();
        }
            public override void GetTexture(Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out RectangleF textureSubRectangle)
            {
                if (_synchronizedTexture == null)
                {
                    _drawingSurfaceUpdateHandler.CreateDeviceResources();
                    _drawingSurfaceUpdateHandler.CreateWindowSizeDependentResources(surfaceSize);
                    _synchronizedTexture = _host.CreateSynchronizedTexture(_drawingSurfaceUpdateHandler._renderTarget);
                }

                synchronizedTexture = _synchronizedTexture;
                textureSubRectangle = new RectangleF
                {
                    Right  = surfaceSize.Width,
                    Bottom = surfaceSize.Height
                };

                _surfaceUpdateHandler.UpdateGameWindowSize(surfaceSize);

                _synchronizedTexture.BeginDraw();

                _surfaceUpdateHandler.Draw(
                    _drawingSurfaceUpdateHandler._device,
                    _drawingSurfaceUpdateHandler._deviceContext,
                    _drawingSurfaceUpdateHandler._renderTargetView);

                _synchronizedTexture.EndDraw();
            }
Beispiel #3
0
        /// <summary>
        /// Gets the texture.
        /// </summary>
        /// <param name="surfaceSize">Size of the surface.</param>
        /// <param name="synchronizedTexture">The synchronized texture.</param>
        /// <param name="textureSubRectangle">The texture sub rectangle.</param>
        public override void GetTexture(SDX.Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out SDX.RectangleF textureSubRectangle)
        {
            if (m_surfacePainter == null)
            {
                throw new ObjectDisposedException("WP8DrawingSurfaceInterop");
            }

            EngineDevice currentDevice = m_surfacePainter.RenderLoop.Device;
            Size2        pixelSize     = m_surfacePainter.GetCurrentRenderTargetSize();

            // Create the synchronized texture if needed
            if ((m_backBufferWP8Sync == null) ||
                (m_lastPixelSize != pixelSize) ||
                (m_lastDevice != currentDevice))
            {
                // Dispose previously created buffers
                GraphicsHelper.SafeDispose(ref m_backBufferWP8Sync);
                GraphicsHelper.SafeDispose(ref m_backBufferWP8);

                // Create backbuffers for xaml rendering
                m_backBufferWP8     = GraphicsHelper.CreateSharedTextureWP8Xaml(currentDevice, pixelSize.Width, pixelSize.Height);
                m_backBufferWP8Sync = m_runtimeHost.CreateSynchronizedTexture(m_backBufferWP8);

                m_lastPixelSize = pixelSize;
                m_lastDevice    = currentDevice;
            }

            // Copy contents of current back buffer to synchronized texture
            m_backBufferWP8Sync.BeginDraw();
            try
            {
                D3D11.Texture2D sourceRenderTarget = m_surfacePainter.RenderTargetForSynchronization;

                currentDevice.DeviceImmediateContextD3D11.ResolveSubresource(
                    sourceRenderTarget, 0, m_backBufferWP8, 0, GraphicsHelper.DEFAULT_TEXTURE_FORMAT_SHARING);
                currentDevice.DeviceImmediateContextD3D11.Flush();
            }
            finally
            {
                m_backBufferWP8Sync.EndDraw();
            }

            // Reset request counter
            m_frameRequestCount = 0;

            // Set return parameters
            synchronizedTexture = m_backBufferWP8Sync;
            textureSubRectangle = new SDX.RectangleF(0f, 0f, surfaceSize.Width, surfaceSize.Height);
        }
        public override void GetTexture(SharpDX.Size2F surfaceSize, out DrawingSurfaceSynchronizedTexture synchronizedTexture, out SharpDX.RectangleF textureSubRectangle)
        {
            if (_synchronizedTexture == null)
            {
                _synchronizedTexture = _host.CreateSynchronizedTexture(_controller.GetTexture());
            }

            // Set output parameters.
            _textureSubRectangle.Left = 0.0f;
            _textureSubRectangle.Top = 0.0f;
            _textureSubRectangle.Right = surfaceSize.Width;
            _textureSubRectangle.Bottom = surfaceSize.Height;

            //HOW DO YOU DO A Microsoft::WRL::ComPtr<T>   CopyTo ?????
            //m_synchronizedTexture.CopyTo(synchronizedTexture);
            synchronizedTexture = _synchronizedTexture;

            textureSubRectangle = _textureSubRectangle;

            //something is going wrong here as the second time thru the BeginDraw consumes
            //the call and controlnever returns back to this method, thus GetTexture
            //(the call after begindraw) never fires again... ??????
            synchronizedTexture.BeginDraw();

            _controller.GetTexture(surfaceSize, synchronizedTexture, textureSubRectangle);

            synchronizedTexture.EndDraw();
        }